MongoDB Flashcards

1
Q

What is MongoDB

A

No SQL or non-relational database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Collection

A

A group of documents in MongoDB. Do not enforce a rigid schema

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Document

A

a record stored in JSON-like format, and each document in the collection has a different structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Visualize a collection

A

db.users({“name”:”Bob”, “age”:30}, {name:”Charlie”, “age”:35, “Hobbies”:[“cycling”,”hiking”]})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Visualize a document

A

{“name”: “Alicce”, “age”:25}
documents ae stored ({..})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Query using .find()

A

db.collection.find()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Query with a condition

A

$gt
db.collection.find({“condition”:{“$gt”:x})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Update a single document in a collection

A

$set
db.collection.updateOne({“name”:”Alice”},{“$set”:{“age”:26}})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Delete a single document

A

.deleteOne
db.collection.deleteOne({“name”:”Alice”})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Delete multiple documents

A

.deleteMany
db.users.deleteMany(“age”:{“$lt”:30}}) // Delets users younger than 30

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Delete a collection

A

.drop()
db.collection.drop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly