mongo Flashcards

1
Q

mongo: To install and run mongo, type

A

brew install mongodb
mkdir -p /data/db
sudo chmod 777 /data/db
mongod

new terminal–
mongo

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

mongo: To show all databases, type

A

show dbs

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

mongo: To create a new db, type

A

use databaseName

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

mongo: A db will not show up in show dbs if

A

If there is not data in it

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

mongo: To see all collection form inside a db, type

A

show collections

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

mongo: To return only 10 documents from a collection, type

A

db.collectionName.find().limit(10)

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

mongo: In mongo a foreign key is called a

A

reference field

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

mongo: A reference field should contain

A

ObjectID(“string”)

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

mongo: To see the files in the current directory, type

A

ls()

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

mongo: To load data into mongo, type

A

load(“./file.js”)

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

pymongo: To get access to a database in mongodb, type

A

from pymongo import MongoClient
client = MongoClient(‘mongoURI’) # Find on mongolab
db = client.database_name

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

pymongo; To create a new collection, type

A

db.new_collection_name.insert_one({“key”:”value”})

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

pymongo: To easily insert a df into a mongo collection, type

A

from odo import odo

odo(df, db.collectionName)

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

ipython: To run normal shell commands inside a notebook, type

A

! before the command

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