Skip to content

Extend options arg to support custom model definitions #49

Closed

Description

@bajtos

Extend the options argument of boot/compile to allow the developer to supply custom model definitions (to replace the result of findModelDefinitions). Together with the existing options.models, it will allow you to specify all model-related data and still use the benefits which loopback-boot provides (most notably loading models in order defined by inheritance, i.e. base models are loaded before models that are extending them).

boot(app, {
  models: {
    Car: { dataSource: 'db' },
    // etc.
  },
  modelDefinitions: [
     {
       definition: {
         name: 'Car',
         properties: { /*...*/ }
       },
       sourceFile: 'path/to/car.js'
    },
    // etc.
  ]
});

This is a follow-up for #27.

Activity

  1. self-assigned this
    on Oct 3, 2014
  2. STRML commented on Nov 13, 2014

    @STRML
    Member

    Thanks. I'm attempting to upgrade to loopback-boot 2.0 but this is a blocker for me. My use case is essentially model schema discovery from a custom (unsupported) database. In 1.0 I simply ran a function that modified the JSON configuration before passing to loopback-boot. I am thinking of simply implementing dataSource.discoverSchema for this custom connector - do you have any examples of that data that being merged into the models passed to loopback-boot?

  3. bajtos commented on Nov 13, 2014

    @bajtos
    MemberAuthor

    I am thinking of simply implementing dataSource.discoverSchema for this custom connector - do you have any examples of that data that being merged into the models passed to loopback-boot?

    My knowledge of schema discovery is very limited, @raymondfeng knows much more. I believe the result of dataSource.discoverySchema is mostly the same as the content of common/models/model-name.json.

  4. bajtos commented on Nov 13, 2014

    @bajtos
    MemberAuthor

    Thanks. I'm attempting to upgrade to loopback-boot 2.0 but this is a blocker for me.

    I am afraid this issue is not a priority for us at the moment, thus I won't have time to implement it anytime soon. Can you contribute the implementation yourself?

  5. STRML commented on Nov 13, 2014

    @STRML
    Member

    I’m going to see what I can do with discovery - from there I’ll contribute if anything gets in my way, and at least attach an example to this ticket. Thanks.

    On Nov 13, 2014, at 3:07 PM, Miroslav Bajtoš notifications@github.com wrote:

    Thanks. I'm attempting to upgrade to loopback-boot 2.0 but this is a blocker for me.

    I am afraid this issue is not a priority for us at the moment, thus I won't have time to implement it anytime soon. Can you contribute the implementation yourself?

    —
    Reply to this email directly or view it on GitHub #49 (comment).

  6. shlomiassaf commented on Feb 21, 2015

    @shlomiassaf
    Contributor

    @bajtos,

    I sent PR for this enhancement, #96
    Could you please check?

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions