Reputation: 380
I tried this statement: SELECT * FROM table_name It did not work. What is the command or method to select all rows from a table in Mongodb?
Upvotes: 19
Views: 64419
Reputation: 26444
MongoDB is a different type of database than your traditional RDBMS. Instead of tables, Mongo uses collections and instead of rows, Mongo uses documents.
The way to do this in Mongo is as follows
db.collectionName.find()
This will return a collection of objects
{"_id": ObjectId("559d85cc9ab227e79da027252"), "name": "Edward"},
{"_id": ObjectId("559d85ef9ab227e79da027252"), "name": "Joseph"}
An excellent resource for Comparison is
https://www.mongodb.com/compare/mongodb-mysql
Upvotes: 29