Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver Interface #776

Closed
jpventura opened this issue Dec 6, 2017 · 4 comments
Closed

Driver Interface #776

jpventura opened this issue Dec 6, 2017 · 4 comments
Assignees

Comments

@jpventura
Copy link

jpventura commented Dec 6, 2017

Description/Steps to reproduce

I've started using LoopBack because the connectors and datasources seemed like a canned solution for fast integration with RESTful APIs with API Blueprints or Swagger specifications.

However, while I was trying to create a simple tutorial app, I discovered that it is not possible to automagically consume the API because the server might not provide all CRUD functionalities required by PersistentModel.

Even if Pet Store or TMDB were written in Swagger, the auto import would not be possible.

Driver Interface

Waterline adapters are similar to connectors, except for the fact they define a standard driver interface should provide:

  • Connectable
  • Modeled
  • Queryable
  • Migratable
  • Cache
  • Transactional
  • Tradeable

As mentioned at #537, queries would be written in Knex.js language to provide queries.

Expected result

Providing standard methods similar to the driver interface would help juggler to inspect datasources, allowing we faster abstract any kind of local/remote data access.

Also it would be possible to provide an elegant query language:

Pet.find({
    or : [
      { name: 'walter' },
      { occupation: 'teacher' }
    ]
});
@Untel
Copy link

Untel commented Dec 7, 2017

I used Sails before Loopback, and had to change Waterline for Sequilize (not without pain).
Waterline don't support Deep populate, polymorphism, and some other things.
The Loopback 2/3.x connectors where such better.
In case where the LB4 team don't develop their own orm, i think it should be better to use TypeORM or Sequalize with typescript definition, than Waterline

@kjdelisle
Copy link
Contributor

We do intend to have a Juggler in v4 as per the discussion in #537, though we will be simplifying it somewhat to reduce friction between datasources and make it easier to support more widely.

@Untel
The good news is that the way we've designed the framework for LB4, you can make use of whatever ORM you'd like and keep the protocol-facing portions. Here's a prototype mixin that adds TypeORM as a part of the Application class: https://github.com/strongloop/loopback4-extension-typeorm

It's not necessarily a production-ready mixin per se, but it does demonstrate how you can still leverage LoopBack 4's Application, Context and Controller patterns with a totally different ORM.

@bajtos
Copy link
Member

bajtos commented Dec 7, 2017

@jpventura thank you for opening this issue.

However, while I was trying to create a simple tutorial app, I discovered that it is not possible to automagically consume the API because the server might not provide all CRUD functionalities required by PersistentModel.

I took a look at your tutorial application. As far as I understand, it's a typical LoopBack 3.x application. It makes we wonder, how did you reach the conclusion that "it is not possible to automagically consume the API because the server might not provide all CRUD functionalities required by PersistentModel."?

First of all, @loopback/repository is using loopback-datasource-juggler 3.x and it's PersistedModel under the hood, therefore all data-access APIs are available (even if not exposed via DefaultCrudEntityRepository).

Are you perhaps referring to the REST API layer? This is something we have to figure out yet. I am personally proposing the approach where controller methods are generated by our CLI tooling, as I have explained in great length in my comment #485 (comment) about migration from LB 3.x to 4.x. There is also a pull request in review that creates a controller base class providing a common CRUD REST endpoints - see #740.

Setting aside the fact that I don't understand what is the problem you are facing and how Waterline is going to solve that, I'd like to second what @kjdelisle said in the comment above - we have specifically designed LoopBack 4 to allow developers to use a different ORM instead of our juggler. Of course, you would have to write your CRUD controller methods yourself.

except for the fact they define a standard driver interface

Our controllers do have a standard driver interface, even if it's not as well documented as Waterline's. See the following two pages for more information:

Providing standard methods similar to the driver interface would help juggler to inspect datasources, allowing we faster abstract any kind of local/remote data access.

We have APIs for inspecting database schemas in juggler (is that what you meant?), there is even a basic templated implementation for SQL connectors - see the code in SqlConnector.


I feel I may be missing the point you are trying to make, could you please elaborate more on what issues do you see and what real-world scenarios you are not able to accomplish right now?

@jpventura jpventura changed the title Waterline Driver Interface Driver Interface Dec 7, 2017
@bajtos bajtos added the triaging label Jan 2, 2018
@bajtos bajtos self-assigned this Jan 2, 2018
@bajtos
Copy link
Member

bajtos commented Jan 22, 2018

Looks like this proposal does not have enough traction, I am closing this issue for now.

@bajtos bajtos closed this as completed Jan 22, 2018
@bajtos bajtos removed the triaging label Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants