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

$populate does not need to be whitelisted #391

Closed
bwgjoseph opened this issue Jul 26, 2020 · 1 comment
Closed

$populate does not need to be whitelisted #391

bwgjoseph opened this issue Jul 26, 2020 · 1 comment
Labels

Comments

@bwgjoseph
Copy link
Contributor

bwgjoseph commented Jul 26, 2020

The docs (https://github.com/feathersjs-ecosystem/feathers-mongoose#populate) indicate that in order to use $populate, one would need to define $populate in the whitelist option when declaring a service..

app.use('/posts', mongoose({
  Model,
  whitelist: [ '$populate' ]
});

However, that does not seem to be the case.. To replicate..

mkdir feathers-populate
feathers g app
feathers g service | Post and Comment
leave everything as default except Post schema below

const schema = new Schema({
    text: { type: String, required: true },
    commentIds: [
      {
        type: Schema.Types.ObjectId,
        ref: 'comment',
      },
    ]
  }

Perform a REST call via localhost:3030/post?$populate[]=commentIds

This is without populate via REST call

{
    "total": 1,
    "limit": 10,
    "skip": 0,
    "data": [
        {
            "_id": "5f1d9420e8c36b5750baad43",
            "commentIds": [
                "5f1d93f4e8c36b5750baad41",
                "5f1d9400e8c36b5750baad42"
            ],
            "text": "post 1",
            "createdAt": "2020-07-26T14:33:04.752Z",
            "updatedAt": "2020-07-26T14:33:04.752Z",
            "__v": 0
        }
    ]
}

and this is with populate call

{
    "total": 1,
    "limit": 10,
    "skip": 0,
    "data": [
        {
            "_id": "5f1d9420e8c36b5750baad43",
            "commentIds": [
                {
                    "_id": "5f1d93f4e8c36b5750baad41",
                    "text": "comment 1",
                    "createdAt": "2020-07-26T14:32:20.751Z",
                    "updatedAt": "2020-07-26T14:32:20.751Z",
                    "__v": 0
                },
                {
                    "_id": "5f1d9400e8c36b5750baad42",
                    "text": "comment 2",
                    "createdAt": "2020-07-26T14:32:32.591Z",
                    "updatedAt": "2020-07-26T14:32:32.591Z",
                    "__v": 0
                }
            ],
            "text": "post 1",
            "createdAt": "2020-07-26T14:33:04.752Z",
            "updatedAt": "2020-07-26T14:33:04.752Z",
            "__v": 0
        }
    ]
}

Related to: feathersjs/feathers#1971

@stale
Copy link

stale bot commented Nov 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant