MongoDB Flashcards
The base of traditional relational database management systems:
Atomicity: All operations in a transactionsucceeds or rolled back.
Consistency: After a transaction completed, the database remains consistence.
Isolation: Transactions are executed without interfering with other transactions.
Durability: After a transaction completed, changes will be permanent.
Define NoSQL
No SQL is a generic term that refers to any non-relational data management system and does not use SQL query language.
MongoDB features:
Indexing
Aggregations
File Storage
Special collection types
Create a collection named “newCollection” and insert the field “field” and the value “value :
> db.newCollection.insertOne({“field” : “value”})
Create a database named “myNewDb”
> use myNewDb
Drop the current database
db.dropDatabase()
Add one document to the collection “TestKey” with an id of 1 and a name of “test2”
db.TestKey.insertOne({_id:1, Name: “test2”})
The command to insert multiple documents into a collection:
db.collection.insertMany([
{ // fields and values } ,
{ // fields and values }
])
display the “Employee” collection
db.Employee.find()
OR
db.Employee.find().pretty()
display all databases
show dbs
display collections of current database
show collections
show all the collections in an array:
db.getCollectionNames()
drop the collection “Dept”
db.Dept.drop()
create a collection named “Room”
db.createCollection(“Room”)
Remove all documents in the collection “foo”
db.foo.remove()