-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongo.js
58 lines (41 loc) · 3.17 KB
/
mongo.js
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
Comandos:
-use ecommerce
db.createCollection("mensajes")
db.createCollection("productos")
db.productos.insertMany([
{title: "Heladera Carrier", description:"Heladera inverter",price:70000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Conservadora", description:"Ahora que se viene el veranito",price:6000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Microondas", description:"Calentate rapido la comida",price:40000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Cafetera", description:"Cafetera para arrancar la mañana con toda",price:10000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Yogurthera", description:"Yogurthera pa hacerse desayuno",price:3000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Aire acondicionado", description:"Aire acondicionado etc etc",price:80000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Termo Stanley", description:"Termo Stanley etc etc",price:11000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Lavarropas", description:"Lavarropas etc etc",price:52000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Freezer", description:"Freezer etc etc",price:65000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
{title: "Televisor smart", description:"Televisor smart etc etc",price:86000,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"},
])
db.mensajes.insertMany([
{message: "hola como andas", email:"[email protected]"},
{message: "Bien y vos?", email:"[email protected]"},
{message: "Todo tranquilo, que andás haciendo?", email:"[email protected]"},
{message: "Acá haciendo una entrega del curso, vos?", email:"[email protected]"},
{message: "Si yo tambien, estoy dando mongodb", email:"[email protected]"},
{message: "Yo tambien!", email:"[email protected]"},
{message: "Está bueno, encima el tutor es re buena onda", email:"[email protected]"},
{message: "Si, el mio tambien!", email:"[email protected]"},
{message: "Tambien es muy bueno el profe", email:"[email protected]"},
{message: "Un exito!", email:"[email protected]"},
])
db.productos.find().pretty()
db.mensajes.find().pretty()
db.productos.count()
db.productos.count()
db.productos.insertOne({title: "Monitor samsung", description:"Monitor ultra hd",price:34675,thumbnail:"https://http2.mlstatic.com/D_NQ_NP_781119-MLA31632168129_072019-O.jpg"})
db.productos.find({price:{$lt:1000}})
db.productos.find({price:{$in:[1000,3000]}})
db.productos.find({price:{$gt:3000}})
db.productos.find({},{"title":1}).sort({price:1}).skip(2).limit(1)
db.productos.updateMany({},{$set:{stock:100}})
db.productos.updateMany({price:{$gt:20000}},{$set:{stock:0}})
db.productos.deleteMany({price:{$lt:10000}})
db.createUser({user:"pepe",pwd:"asd456",roles:[{role:"read",db:"ecommerce"}]})