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

findByIdDeleted not working as described #11

Open
DashBarkHuss opened this issue Jun 2, 2021 · 1 comment
Open

findByIdDeleted not working as described #11

DashBarkHuss opened this issue Jun 2, 2021 · 1 comment

Comments

@DashBarkHuss
Copy link

The findByIdDeleted method isn't working as described in the docs.

In the docs it says that findByIdDeleted takes a callback that returns a document

Sample.findByIdDeleted(sampleId, function(err, doc) {
    //doc.deletedAt will be current timestamp
    //doc.deleted will be true
})

But instead findByIdDeleted isn't doing anything with the callback.

const result = UserModel.findByIdDeleted('60b6dbd320329b2952db39e8', function (err, doc) {
        console.log(err || doc); // code never gets here
 });
 
 result //> returns a query

Also the function returns a model.Query, not a mongoose document:

model.Query {
_collection:NodeCollection {collection: NativeCollection, collectionName: 'users'}
_conditions:{_id: '60b6dbd320329b2952db39e8', deleted: true}
_distinct:undefined
_executionCount:0
_fields:undefined
...
}
@Sanyi002
Copy link

@DashBarkHuss I think you missed an await before your function call, that's the reason why you get back a query not a document.

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