A short practice using MongoDB
use inventario
db.inventario.insertMany([
{item: "journal", qty: 25, tags:["black","red"], dim_cm: [14,21]},
{item: "notebook", qty: 50, tags:["red","blank"], dim_cm: [14,21]},
{item: "paper", qty: 100, tags:["red","blank","pain"], dim_cm: [14,21]},
{item: "planner", qty: 75, tags:["black","red"], dim_cm: [22.85,30]},
{item: "postcard", qty: 45, tags:["blue"], dim_cm: [10,15.25]}
]);
db.inventario.find({ $and: [{"dim_cm": {$gt: 10}}, {"dim_cm": {$lt: 15}} ]});
use tienda;
db.createCollection("telefonos");
db.telefonos.insertMany([{"name": "AC3 phone", "brand": "ACME", "type": "phone", "price": 200, "rating": 3.8, "warranty_years": 1, "available": true},
{"name": "AC7 phone", "brand": "ACME", "type": "phone", "price": 320, "rating": 4, "warranty_years": 1, "available": false},
{"name": "AC3 series charger", "type": ["accesory","charger"], "price": 19, "rating": 2.8, "warranty_years": 0.25, "for": ["ac3", "ac7", "ac9"]},
{"name": "AC3 case green", "type": ["accesory","case"], "color": "green", "price": 12, "rating": 1, "warranty_years": 0 },
{"name": "phone extended warranty", "type": "warranty", "price": 38, "rating": 5, "warranty_years": 2, "for": ["ac3", "ac7", "ac9", "qp7", "qp8", "qp9"] },
{"name": "AC3 case black", "type": ["accesory","case"], "color": "black", "price": 12.5, "rating": 2, "warranty_years": 0.25, "available": false, "for": "ac3"},
{"name": "AC3 case red", "type": ["accesory","case"], "color": "red", "price": 12, "rating": 4, "warranty_years": 0.25, "available": true, "for": "ac3"},
{"name": "phone service basic plan", "type": "service", "monthly_price": 40, "rating": 3, "limits": {"voice": {"units": "minutes", "n": 400, "over_rate": 0.05}, "data": {"units": "gigabytes", "n": 20, "over_rate": 1 }, "sms": {"units": "text sent", "n": 100, "over_rate" :0.001 } }, "term_years" : 2},
{"name": "phone service core plan", "type": "service", "monthly_price": 60, "rating": 3, "limits": {"voice": {"units": "minutes", "n": 1000, "over_rate": 0.05}, "data": { "n": "unlimited", "over_rate": 0 }, "sms": {"n": "unlimited", "over_rate":0} },"term_years" : 1},
{"name": "phone service family plan", "type": "service", "monthly_price": 90, "rating": 4, "limits": {"voice": {"units": "minutes", "n": 1200, "over_rate": 0.05}, "data": { "n": "unlimited", "over_rate": 0 }, "sms": {"n": "unlimited", "over_rate": 0 }}, "sales_tax": true, "term_years": 2}]);
db.telefonos.find({"type": "service"});
db.telefonos.find({ $and: [{"type": "service"}, {"monthly_price": {$gt: 50}} ]});
db.telefonos.find({ $or: [{"type": "service"}, {"monthly_price": {$gt: 50}} ]});
use base1
db.createCollection("articulos");
db.articulos.insertMany([
{ _id: 1, nombre: "impresora lenovo", rubro: "impresora", precio: 150000, stock: 200},
{ _id: 2, nombre: "mouse tk", rubro: "mouse", precio: 80000, stock: 50},
{ _id: 3, nombre: "impresora multifuncional", rubro: "impresora", precio: 200000, stock: 3},
{ _id: 4, nombre: "pantalla lenovo", rubro: "pantalla", precio: 100000, stock: 30},
{ _id: 5, nombre: "teclado hp", rubro: "teclado", precio: 50000, stock: 55},
{ _id: 6, nombre: "audifonos gamer", rubro: "audifonos", precio: 150000, stock: 90}
]);
db.articulos.find();
db.articulos.find({ rubro: {$ne: "impresora"} });
db.articulos.find({"rubro": "mouse"});
db.articulos.find({"precio": { $gte: 5000} });
db.articulos.find({ $and: [{"rubro": "impresora"}, {"precio": {$gte: 3500}} ]});
db.articulos.find( { stock: { $in: [ 0,1,2,3,4 ]} })