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

remove doesn't work #56

Open
kazzacarrot opened this issue May 12, 2017 · 3 comments
Open

remove doesn't work #56

kazzacarrot opened this issue May 12, 2017 · 3 comments

Comments

@kazzacarrot
Copy link
Contributor

After my solution didn't pass, and I couldn't debug my own,
I copied your solution into "re.js" and ran 'learnyoumongo run re.js` -> This is the output

Expected document to be removed [ { _id: '554a655c0639034860349353', name: 'blah' } ]
@hwangm
Copy link

hwangm commented Sep 12, 2017

@kazzacarrot Here's my code if you want to compare - it passes run and verify. In the official MongoDB Node api notes, remove() has been deprecated in favor of deleteOne() or deleteMany().

var mongo = require('mongodb').MongoClient;

var url = 'mongodb://localhost:27017/'+process.argv[2];

mongo.connect(url, (err, db) => {
        if (err) throw err;
        var coll = db.collection(process.argv[3]);
        var id = process.argv[4];
        coll.deleteOne({
                _id: id
        }, (err, data) => {
                if (err) throw err;
                db.close();
        });
});

@snehal96
Copy link

snehal96 commented Jan 26, 2018

@hwangm, I copy pasted your code and it still shows the same error for me.













Expected document to be removed [ { _id: '554a655c0639034860349353', name: 'blah' } ]

Mongodb version:






MongoDB shell version v3.6.2
git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
allocator: tcmalloc
modules: none
build environment:
distmod: amazon
distarch: x86_64
target_arch: x86_64

P.S.: I am using amazon clod 9 ide.

@hwangm
Copy link

hwangm commented Jan 26, 2018

@snehal96 Have you looked at the solutions updated for mongodb 3+?
https://github.com/nachoperassi/learnyoumongo

Perhaps there was some change that makes my solution invalid now, I'm not sure since it was a while ago now.

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

3 participants