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

How to AutoPopulate inside a object #58

Closed
suryabigapp opened this issue Dec 10, 2019 · 2 comments
Closed

How to AutoPopulate inside a object #58

suryabigapp opened this issue Dec 10, 2019 · 2 comments

Comments

@suryabigapp
Copy link

status: {
      type: {
        id: {
          type: ObjectId,
          ref: 'CustomerStatus',
          autopopulate: { select: 'title' },
        },
        updatedBy: {
          type: ObjectId,
          ref: 'User',
          autopopulate: { select: 'name' },
        },
        updatedAt: {
          type: Date,
        },
      },
    },

Something like this

@suryabigapp suryabigapp changed the title AutoPopulate inside a object How to AutoPopulate inside a object Dec 10, 2019
@vkarpov15
Copy link
Member

Remove the type key, because as written, your schema defines status as a Mixed path, and autopopulate doesn't look underneath mixed paths.

status: {
      //type: {
        id: {
          type: ObjectId,
          ref: 'CustomerStatus',
          autopopulate: { select: 'title' },
        },
        updatedBy: {
          type: ObjectId,
          ref: 'User',
          autopopulate: { select: 'name' },
        },
        updatedAt: {
          type: Date,
        },
      },
    },

@vkarpov15
Copy link
Member

See Automattic/mongoose#7181

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