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

Declare relationship one-to-many #32

Closed
hoangzinh opened this issue Feb 25, 2017 · 1 comment
Closed

Declare relationship one-to-many #32

hoangzinh opened this issue Feb 25, 2017 · 1 comment

Comments

@hoangzinh
Copy link

VERSIONS
Trailpack-mongoose: 2.1.0
Trailpack-express: 2.0.3
Trailpack-footprints: 2.0.0,

DETAIL
Follow documentation on Trailpack-mongoose and Mongoose itself. If we want to declare relationship between one-to-many. We can do as follow:

static schema (app, Mongoose) {
    return {
      childs: [{
        type: Mongoose.Schema.ObjectId,
        ref: 'UserSchema'
      }],
    }
  }

But I always get errors to

Error: No such reference exist
    at FootprintService.createAssociation

When I try make a request to /user/:id/childs

It works only I update the User schema to

     childs: {
        type: [ Mongoose.Schema.ObjectId ],
        ref: 'UserSchema'
      }

Do we have different convention with mongoose when declare relationship one-to-many?

@konstantinzolotarev
Copy link
Collaborator

@hoangzinh To be honest I never used such definition.
Sorry for that.
I'll push a fix asap

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

2 participants