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

cannot remove a document #166

Closed
alexwang2013 opened this issue May 7, 2015 · 2 comments
Closed

cannot remove a document #166

alexwang2013 opened this issue May 7, 2015 · 2 comments

Comments

@alexwang2013
Copy link

   var ObjectID = req.ObjectID;
    db.collection('prodcuts').remove({_id:ObjectID(productId)}, {safe: true}, function(err, result) {
        console.log(err);
        console.log(result);
        res.send((err === null) ? { msg: '' } : { msg: err });
    });

it output err is null, result is 0, but the document in DB cannot be removed.

and i tried the following, it has the same result. but the document in DB cannot be removed.

  db.collection('prodcuts').remove({name:'bmw')}, {safe: true}, function(err, result) {
        console.log(err);
        console.log(result);
        res.send((err === null) ? { msg: '' } : { msg: err });
    });

anybody could help me for this issue?

Regards

@vkarpov15
Copy link
Contributor

Can you run this command in the mongodb shell successfully? That is, does db.products.remove({ name: 'bmw' }); work?

Also, you may not have noticed but you have a typo in your code, "prodcuts" -> "products"

@alexwang2013
Copy link
Author

Hi, vkarpov15
Thank you so much. I made a mistake on the spell. it should be "prodcuts" -> "products".
All the statements works fine.
Thank you very much. you solved a problem for me that it took me more than 8 hours :)

Alex

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