Mongodb compass: visual interface to mongo db
Atlas: mongo’s database as a service
Refering to a collection from database -> database.table
Documents are stored in collections, database can have more collections.
You may use any supported value type for any field value or array elment in a mongodb
document.
MongoDB provides specific support for documents, arrays, and geospatial data.
JSON documents:
- begin and end with { }
- are composed of fields: “key”:”value”, / / commas seperate the fields
- Arrays are in normal brackets:
ex. {“end station name”Broadway”}
RANGE FILTER
{'birth year': {$gte: 1985,$lt: 1990}} // $gte = greater than or equal to, $lt = less than
CRUD: create, read, update, delete
Replica sets are designed so that if the primary node goes down, one of the other nodes will
step up to take its place so that clients can continue reading and writing data as if nothing
had happened.
insertOne()
1. Select database (use video), via show collections you can see all the databases
2. ex query: db.moviesScratch.insertOne({title: "Star Trek II: The Wrath of Khan", year:
1982, imdb: "tt0084726"})
insertMany() ->
- ORDERED: as soon as an error encouters, insertMany stops inserting:
db.moviesScratch.insertMany(
[
, {
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
},
{
"_id" : "tt0796366",
"title" : "Star Trek",
"year" : 2009,
"type" : "movie"
},
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
},
{
"_id" : "tt1408101",
"title" : "Star Trek Into Darkness",
"year" : 2013,
"type" : "movie"
},
{
"_id" : "tt0117731",
"title" : "Star Trek: First Contact",
"year" : 1996,
"type" : "movie"
}
],
);
- UNORDERED: continues after getting an error
db.moviesScratch.insertMany(
[
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
Atlas: mongo’s database as a service
Refering to a collection from database -> database.table
Documents are stored in collections, database can have more collections.
You may use any supported value type for any field value or array elment in a mongodb
document.
MongoDB provides specific support for documents, arrays, and geospatial data.
JSON documents:
- begin and end with { }
- are composed of fields: “key”:”value”, / / commas seperate the fields
- Arrays are in normal brackets:
ex. {“end station name”Broadway”}
RANGE FILTER
{'birth year': {$gte: 1985,$lt: 1990}} // $gte = greater than or equal to, $lt = less than
CRUD: create, read, update, delete
Replica sets are designed so that if the primary node goes down, one of the other nodes will
step up to take its place so that clients can continue reading and writing data as if nothing
had happened.
insertOne()
1. Select database (use video), via show collections you can see all the databases
2. ex query: db.moviesScratch.insertOne({title: "Star Trek II: The Wrath of Khan", year:
1982, imdb: "tt0084726"})
insertMany() ->
- ORDERED: as soon as an error encouters, insertMany stops inserting:
db.moviesScratch.insertMany(
[
, {
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
},
{
"_id" : "tt0796366",
"title" : "Star Trek",
"year" : 2009,
"type" : "movie"
},
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",
"year" : 1982,
"type" : "movie"
},
{
"_id" : "tt1408101",
"title" : "Star Trek Into Darkness",
"year" : 2013,
"type" : "movie"
},
{
"_id" : "tt0117731",
"title" : "Star Trek: First Contact",
"year" : 1996,
"type" : "movie"
}
],
);
- UNORDERED: continues after getting an error
db.moviesScratch.insertMany(
[
{
"_id" : "tt0084726",
"title" : "Star Trek II: The Wrath of Khan",