This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"_id":"557a723880a20c9db3bc31c2","pkdx_id":1,"national_id":1,"name":"Bulbasaur","__v":3,"image_url":"http://pokeapi.co/media/img/1.png","description":"Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger. Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.","art_url":"http://assets22.pokemon.com/assets/cms2/img/pokedex/full/001.png","types":["poison","grass"],"evolutions":[{"level":16,"method":"level_up","to":"Ivysaur","_id":"557a723880a20c9db3bc31c3"}]} | |
{"_id":"557a723980a20c9db3bc31e3","pkdx_id":2,"national_id":2,"name":"Ivysaur","__v":4,"image_url":"http://pokeapi.co/media/img/2.png","description":"There is a bud on this Pokémon's back. To support its weight, Ivysaur's legs and trunk grow thick and strong. If it starts spending more time lying in the sunlight, it's a sign that the bud will bloom into a large flower soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.accounts.insertMany([ | |
{"_id": 1, "credits": 5000, "expenses": [2000, 2000]}, | |
{"_id": 2, "credits": 4000, "expenses": [1000, 4000, 2000]}, | |
{"_id": 3, "credits": 3000, "expenses": [1500, 750]}, | |
{"_id": 4, "credits": 2000, "expenses": [2500, 750]} | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.accounts.find({ | |
$expr : { | |
$gt : [ | |
{ $sum : ["$expenses"] }, | |
"$credits" | |
] | |
} | |
}) | |
{ "_id" : 2, "credits" : 4000, "expenses" : [ 1000, 4000, 2000 ] } | |
{ "_id" : 4, "credits" : 2000, "expenses" : [ 2500, 750 ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.accountsWithDate.insertMany([ | |
{"_id": 1, "credits": 5000, "expenses": [2000, 2000], "date": new ISODate("2018-05-01T12:42:10.318Z")}, | |
{"_id": 2, "credits": 4000, "expenses": [1000, 4000, 2000], "date": new ISODate("2018-05-01T22:21:50.015Z")}, | |
{"_id": 3, "credits": 3000, "expenses": [1500, 750], "date": new ISODate("2018-05-02T07:01:20.259Z")}, | |
{"_id": 4, "credits": 2000, "expenses": [2500, 750], "date": new ISODate("2018-05-03T16:39:05.120Z")} | |
]) | |
> db.accountsWithDate.createIndex({"date": 1}) | |
> db.accountsWithDate.find({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.alphabet.insert({ | |
"_id": "00000", | |
"array": ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] | |
}) | |
// We missed the 'i'! | |
// Let's add it in the position before the last element. | |
> db.alphabet.update( | |
{ "_id": "00000" }, | |
{ | |
$push: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.alphabet.insert({ | |
"_id": "11111", | |
"array": ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j'] | |
}) | |
// We missed the 'i'! | |
// Let's add it in the position before the last element. | |
> db.alphabet.update( | |
{ "_id": "11111" }, | |
{ | |
$push: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.alphabet.insert({ | |
"_id": "22222", | |
"array": ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j'] | |
}) | |
// We missed the 'i'! | |
// Let's add it in the position before the last element. | |
> db.alphabet.update( | |
{ "_id": "22222" }, | |
{ | |
$push: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.alphabet.insert({ | |
"_id": "33333", | |
"array": ['a', 'b', 'c', 'd', 'e', 'i', 'j'] | |
}) | |
// We missed the 'f', the 'g', and the 'h'! | |
// Let's add them in the position before the last two elements. | |
> db.alphabet.update( | |
{ "_id": "33333" }, | |
{ | |
$push: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.tracking.insert({ | |
"_id": "44444", | |
"recentItems": ['Apples', 'Bananas', 'Cherries'] | |
}) | |
> db.tracking.update( | |
{ "_id": "44444" }, | |
{ | |
$push: { | |
"recentItems": { | |
$each: ['Dates'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.game.insert({ | |
"_id": "55555", | |
"scores": [223, 220, 190, 176, 151, 139, 124, 123, 80, 57] | |
}) | |
> db.game.update( | |
{ "_id": "55555" }, | |
{ | |
$push: { | |
scores: { | |
$each: [72], |
OlderNewer