Mongo Commands Flashcards

(9 cards)

1
Q

How can I create a new db?

A

implicit with use statement (directory created as soon as data is inserted, there are no empty databases, empty is automatically removed)

-> use newdb

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

How can I insert?

A

dbname.collection.insert({ “field”: 123 })

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

How can I delete?

A

Explicit (drops database with data)
dbname.runCommand({ dropDatabase: 1 })
or with wrapper command
db.dropDatabase()

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

What are capped Collections?

A

collections with a max size defined during creation
- follows the FIFO principle

db.createCollection(“capping”, {capped: true, size:4096, max: 10})

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

What are Time Series Collections?

A

stores sequences of measurements effectively

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

What are Embedded Documents?

A

a field can contain arrays or documents

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

How is a MongoDB find query structured?

A

db.<collection>.find(<criteria>, <projection>)</projection></criteria></collection>

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

What is a MongoDB Cursor?

A

When running find, the result is returned as a cursor / a iterator over a result set.

var cursor = db.<collection>.find({ "user_verified": true }, { text: 1, "user_verified": 1, "user.screen_name": 1, "user.friends_count": 1})</collection>

further cursor commands in pdf 4

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