Mongo DB
1
Arbiters always have exactly __ vote election. Used to decide primary with even # of secondaries.
no
Can you index compound index for 2 arrays
reporting and backups
Hidden members do not receive reads. Therefore the only traffic they receive is basic replication. This makes them good for ___ and creating ____.
$not
Inverts the effect of a query expression and returns documents that do not match the query expression.
$in
Matches any of the values specified in an array
j: true
MongoDB returns only after the requested number of members, including the primary, have written to the journal.
schemas
Mongoose _____ maps to a MongoDB collection
$slice
Returns a subset of an array.
delayed
This member of a replica set should be hidden, has a priority of 0, and set on a delay. "Rolling backup"
$unset
This operator will delete a particular field.
csv
You can connect to multiple members of the replica set using this list ___.
document databases
excel at storing objects
User.find({name: "deadpool"}, callback)
find "deadpool" in User collection. Mongoose
arbiter
in a replicate set the ___ node does not have a copy of data set and cannot become a primary.
$nin
value not in an array
hidden
A ___ member maintains a copy of the primary's data set but is invisible to client applications. Must be priority 0 members.
true
A copy of the oplog is kept on both the primary and secondary servers. T/F?
read
A priority 0 member maintains a copy of the data set, accepts ___ operations, and votes in elections.
0
A priority __ member is a secondary that cannot become a primary. These members cannot trigger elections.
$
Acts as a placeholder to update the first element that matches the query condition in an update.
$push
Adds an item to an array.
primary
After database operations performed on this replica set member ___ , then record the operations on the primary's oplog.
$concatArrays
Concatenates arrays to return the concatenated array.
db.collection.createIndex({ name: 1})
Create an index on the property name_id, ascending
db.collection.createIndex({age_id: -1, height: 1})
Create an multikey index on the age_id property descending and height ascending.
db.collection.createIndex({"people.name": 1})
Create an multikey index on the people array containing objects for property name
db.collection.createIndex({"student_id: 1"}, {unique: true })
Create an unique index for student_id ascending
$unwind
Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element. aggregation stage
replica
Delayed members contain copies of a replica set's data set.
$isArray
Determines if the operand is an array. Returns a boolean.
one
How many members do you need to connect to in a replicate set to automatically detect the other members ___?
db.collection.insert
In MongoDB __ __ __ method adds new documents into a collection
db.collection.remove()
In MongoDB __ __ __ method removes documents from a collection
db.collection.find
In MongoDB __ __ __ method retrieves documents from a collection.
$and
Joins query clauses with a logical AND returns all documents that match the conditions of both clauses.
$nor
Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
$or
Joins query clauses with logical OR returns all documents that match the conditions of either clause.
$limit
Limits the number of documents passed to the next stage in the pipeline. aggregation stage
$all
Matches arrays that contain all elements specified in the query.
$exists
Matches document that have specified field.
$each
Modifies the $push and $addToSet operators to append multiple items for array updates.
$slice
Modifies the $push operator to limit the size of updated arrays.
$sort
Modifies the $push operator to reorder documents stored in array.
$position
Modifies the $push operator to specify the position in the array to add elements.
document
MongoDB is a type of NoSQL database that is a _____ database.
object document mapper
Mongoose is an ____ for MongoDB.
sparse indexes,
Only contain entries for documents that have the indexed field, even if the index field contains a null value.
$match
Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields. aggregation stage
$project
Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields. aggregation stage
$pop
Removes the first or last item of an array.
db.collection.replaceOne(filter, replacement, options)
Replaces a single document within the collection based on the filter
true
Replication supports mixed-mode storage engines. For examples, a mmapv1 primary and wiredTiger secondary.
w:1
Requests acknowlegement the write operation has propagated to the standalone mongod or the primary in a replica set.
$sum
Returns a sum of numerical values. Ignores non-numeric values. Changed in version 3.2: Available in both $group and $project stages.
$first
Returns a value from the first document for each group. Order is only defined if the documents are in a defined order. Available in $group stage only.
$push
Returns an array of expression values for each group. Available in $group stage only.
$avg
Returns an average of numerical values. Ignores non-numeric values. Changed in version 3.2: Available in both $group and $project stages.
$arrayElemAt
Returns the element at the specified array index.
$max
Returns the highest expression value for each group. Changed in version 3.2: Available in both $group and $project stages.
$size
Returns the number of elements in the array. Accepts a single expression as argument.
$filter
Selects a subset of the array to return an array with only the elements that match the filter condition.
$type
Selects documents if a field is of the specified type.
$elemMatch
Selects documents if element in the array field matches all the specified $elemMatch conditions.
$size
Selects documents if the array field is a specifed size.
$regex
Selects documents where values match a specified regular expression.
beginning
Should $match come at the beginning or end of the aggregation pipeline? This should limit the total # of documents in the aggregation pipeline.
$skip
Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.
$sort
Sorts all input documents and returns them to the pipeline in sorted order.
$pull
The __ operator removes from an existing array all instances of a value or values that match a specified condition.
w
The __ option waits for server to respond to write.
buffer
The node.js driver will ___ during an election for a new primary in a replica set.
asynchronous
The secondary members copy and apply the primary oplog in an _____ process.
primary
This __ node receives all write operations in a replica set.
$set
This operator replaces the value of a field with the specified value. If it does not exist it will add a new field.
db.collection.updateOne(filter, update, options)
Updates a single document within the collection based on the filter.
db.collection.updateMany(filter, update, options)
Updates multiple documents within the collection based on the filter.
rs.slaveOk()
What command do I run to read from a secondary in replica set in mongo shell?
stale asynchronous
When setting for readConcern is anything other than "local" you may receive ___ data. Data in the secondary may not reflect the most recent write due to ____ replication.
{ background: true }
____ operation so that MongoDB database remains available during the index building operation.
key-value databases
applications with data-schemas easily mapped into key-value pairs
User.findOneAndRemove({name:"deadpool"}, callback)
find User named 'deadpool' and remove from the User collection. Mongoose
User.findOneAndUpdate({name: "deadpool"}, {name:"wolverine"}, callback)
find User named 'deadpool' and update name to 'wolverine' in User collection. Mongoose
User.findByIdAndUpdate(1, {name: "hulk"}, callback)
find User with id 1 and update name to 'hulk in User collection. Mongoose
User.find({}, callback)
find all documents in User collection. Mongoose
User.findById(1, callback)
find by document with user_id 1 in User collection. Mongoose
User.findByIdAndRemove(1, callback)
find user_id 1 and remove from User collection. Mongoose
$gte
greater than or equal to specified value
db.movies.insertMany(document, writeConcern, ordered)
insert many documents into the the movies collection
db.movies.insertOne(document, writeConcern)
insert one document into the movies collection
sharding
is a method for storing data across multiple machines.
storage engine
is the component of the database that is responsible for managing how data is stored, both in memory and on disk
$lte
less than or equal to specifed value
$gt
matches value greater than specified value
cursor.explain()/db.collection.explain()
methods provide statistics about the performance of a query.
mongo.connect(database, callback)
mongo method for connecting to db
rs.status()
mongo shell command to retrieve config file?
WiredTiger
mongodb 3.2 default storage engine
b-tree
mongodb indexes use a ___ data structures
$ne
not equal to specified value
mongorestore
program writes data from a binary database dump created by mongodump to a MongoDB instance.
local
readConcern property ___ reads from the primary reflect the latest writes in absence of failover
majority
readConcern property ____ read operations from the primary or the secondaries have "eventual consistency"
"eventual consistency"
readable members are not required to reflect the latest writes at all times?
secondaries
replicate the primary's oplog and apply the operations to their data sets such that the secondaries' data sets reflect the primary's data set.
db.moviesDetails.find({ rated: "PG-13"}).count
retrieve total number of movies rated PG-13 from the moviesDetails collection
mongod --port 27018
run command line for mongo to run on port 27018
collection scan
scan every document in a collection, to select those documents that match the query statement.
indexes
special data structures that store a small portion of the collection's data set in an easy to traverse form. The index stores the value of a specific field or set of fields, ordered by the value of the field.
cursor.sort(sort)
specifies the order in which the query returns matching documents.Must apply sort() to the cursor before retreiving any documents from the database.
oplog
the ___ is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases
tied
the arbiter could be useful if you have a __ election for primary.
arbiter
this member of the replica set does not have a copy of the data set and cannot become a primary.
local
this readConcern setting is the default. This setting reads fromt the primary reflect the latest writes in absence of a failover
Query#find(criteria callback)
when the query is executed, the result will be an array of documents.