-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo-db-dicas.txt
69 lines (50 loc) · 1.04 KB
/
mongo-db-dicas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
INTERFACES
==========
Compass
mongo shell
Atlas
DATABASES
=========
show dbs
use <db>
COLLECTIONS
===========
show collections
FILTER
======
db.<db>.find({<parametros>}).pretty()
.count()
Busca por elemento no array
---------------------------
find({[key: value]}) - Array exato
find({key: value}) - Array que contem o elemento
find({key.0: value}) - Elemento aparece na primeira posicao
Projecoes
---------
Restricao das colunas desejadas na filtragem
find({<parametros>}, {colunas: <exibir>})
find({'genres': 'Comedy'}, {title: 1, _id: 0})
Exibindo titulo, porem ocultando _id
Update
------
db.movieDetails.updateOne(
{title: "The Martian"},
{
$set: {
poster: "http://ia.media-imdb.com/images/adsf0asdf87afd87asf987asfd987.jpg"
}
})
db.movieDetails.updateOne(
{title: "The Martian"},
{
$set: {
"awards": {
"wins": 8,
"nominations": 14,
"text": "Nominated for 3 Golden Globes. Another 8 wins & 14 nominations"
}
}
});
Operators
---------
$set