Reputation: 347
I'm starting learning and using MongoDB. I'm following a basic sample consisting creating a collection with one document. So I first switched to a test db using use testdb
.
Then I executed this command in order to insert a new document into a new collection:
db.websites.insert({ name: "homepage", _id: "http://www.html.it", tags: ["Development", "Design", "System"]});
This command returned to me: WriteResult({ "nInserted" : 1 })
Finally I wanna show the last inserted document using
db.website.find()
But, (and this is the problem), it returns me nothing!! No errors, no documents...
Any suggestions?
Thanks
Upvotes: 0
Views: 2873
Reputation: 347
As understood by @chf ,the collection name in db.website.find()
command was wrong: the correct one is websites
(with the s).
So the Begineer Guide contains an error.
Thanks to all and sorry for the trivial question.
Upvotes: 0
Reputation: 91
apparently your insertion is correctly done (it's indicated by the output in the shell). To do your test correctly, you have to
db.createCollection('collectionName');
use collectionName;
db.websites.insert({ name: "homepage", _id: "http://www.html.it", tags: ["Development", "Design", "System"]});
db.websites.find();
To find a result, be sure you're using the correct collection before do the command find.
Upvotes: 1