Mongoose Flashcards

1
Q

Terminology

A

Collection

Grouping of MongoDB documents
Equivalent to a Table in SQL

Document

A single { , … }
Which can consist of 1 or many key : value pairs

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

Intro to Mongoose [1]

A

Allow node.js app to talk with MongoDB

Allows the user to define the schema for the documents in a particular collection

npm install mongoose
Create reference to mongoose
const mongoose = require(‘mongoose’);
Create new database, or connect to an existing database

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

Intro to Mongoose [2]

A

Closing connection
mongoose.connection.close();
Create a mongoose scheme

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

Intro to Mongoose [3]

A

Use the scheme to create a Mongoose model

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

Intro to Mongoose [4]

A

Adding a new item to the collection
Create a new object based on the model
Then call .save() on that new object

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

Intro to Mongoose [5]

A

Saving in bulk

.insertMany(, )

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

Intro to Mongoose [6]

A

Reading from your database with Mongoose
.find();

Data Validation with Mongoose
Add validation in the scheme object
Check for the different types of validations in the mongoose documentations

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

Intro to Mongoose [7]

A

Updating and Deleting Data with Mongoose

Update

.updateOne(, , Callback);

Delete

.deleteOne(, Callback);
Establishing Relationships and Embedding Documents using Mongoose
MongoDB - NoSQL is great for 1-to-Many relationships
So for establishing relationships, we modify the schema:
In the “1” schema, place in the key:value pair, the “many schema”

Creating Custom Lists using Express Route Parameters
Creating and responding to a dynamic route

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

Intro to Mongoose [8]

A

Express Route Parameters

$pull
Removes from an existing array all instances of a value or values that matches a specific condition

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