Project 2
db.inventory.insertOne( {
item: "journal",
price: 9.99,
qty: 25,
size: { h: 14, l: 21, w: 1 },
features: "Beautiful, handmade journal.",
categories: ["writing", "bestseller"],
image: "items/journal.jpg"
} )
db.inventory.updateOne(
{ _id: ObjectId("600e814359ba901629a14e13") },
{
$unset: {image: 1, size: 1, qty: 1, price: 1},
$set : {
item: "journal",
features: ["Inner pocket", "Durable cover"],
skus: [ {
sku: "154A",
price: {
base: NumberDecimal(9.99),
currency: "USD"
},
quantity: 20,
options: {
size: { h: 14, l: 21, w: 1 },
features: ["72 sheets of premium lined paper"],
colors: ["brown", "red"],
ruling: "wide",
image: "images/journal1.jpg"
}
}, {
sku: "154B",
price: {
base: NumberDecimal(14.99),
currency: "USD",
discount: NumberDecimal(4.00)
},
quantity: 15,
options: {
size: { h: 18, l: 22, w: 2 },
features: ["140 sheets of premium paper"],
colors: ["brown"],
ruling: "unlined",
image: "images/journals.jpg"
}
} ]
}
}
)
db.customers.createIndex(
{ email: 1 },
{ unique: true }
)
db.customers.createIndex(
{ email: 1 },
{ unique: true }
)
db.runCommand( {
collMod: "customers",
validator: { $jsonSchema: {
bsonType: "object",
required: [ "hashedAndSaltedPassword", "address" ],
properties: {
_id: {
bsonType: "string",
pattern: '.+@.+..+',
description: "must match the email pattern"
},
hashedAndSaltedPassword: {
bsonType: "string",
minLength: 10,
description: "must be a string ten characters long, and is required"
},
address: {
bsonType: "object",
required: [ "street1", "zip" ],
properties: {
zip: {
pattern: "^[0-9]{5}(?:-[0-9]{4})?$",
description: "must match pattern and is required"
},
street1: {
bsonType: "string",
description: "must be a string and is required" },
street2: {
bsonType: "string",
description: "must be a string" }
},
description: "must be an object, and is required"
}
}
} },
} )
db.payments.insertOne( {
customerId: "journalfanatic@e/mail.com",
status: "verified",
gateway: "stripe",
type: "credit",
amount: NumberDecimal(1.00),
card: {
brand: "Visa",
pan: "4242424242424242",
expirationMonth: 1,
expirationYear: 2090,
cvv: 123
}
} )
db.payments.remove( { } )
db.payments.insertOne( {
customerId: "journalfanatic@e/mail.com",
status: "verified",
gateway: "stripe",
type: "credit",
amount: NumberDecimal(1.00),
card: {
brand: "Visa",
panLastFour: "4242",
expirationMonth: 1,
expirationYear: 2090,
cvvVerified: true
}
} )
db.payments.insertOne( {
customerId: "journalfanatic@e/mail.com",
status: "awaitingVerification",
gateway: "stripe",
type: "token",
token: "card_1IDHBZFdjJUqVVV2gPlbz8BC"
} )
db.orders.insertOne( {
customerId: "journalfanatic@e/mail.com",
paymentId: "600e6f37aa2232f59e273082",
paymentStatus: "paid",
status: "shippedAwaitingDelivery",
currency: "USD",
totalCost: NumberDecimal(39.85)
items: [
{ sku: "154B",
quantity: "2",
price: NumberDecimal(14.99),
discount: NumberDecimal(1.00),
preTaxTotal: NumberDecimal(27.98),
tax: NumberDecimal(1.00),
total: NumberDecimal(28.98),
}, { sku: "154A",
quantity: "1",
price: NumberDecimal(9.99),
preTaxTotal: NumberDecimal(9.99),
tax: NumberDecimal(.87),
total: NumberDecimal(10.86)
}
],
shipping: {
address:{
street1: "50 Work Street",
street2: "Floor 16",
city: "Chicago",
state: "IL",
country: "USA",
zip: "60601"
},
origin: {
street1: "1 Penn Ave",
street2: "",
city: "New York",
state: "NY",
country: "USA",
zipCode: "46281"
},
carrier: "USPS",
tracking: "123412341234"
}
} )
Use ecommerce;
db.customer.insertMany([
{_id:1,"name":"Ganesh","age":23,"city":"amalapuram","type:"premium"},
{_id:2,"name":"Bala","age":22,"city":"Vizag","type:"premium"},
{_id:3,"name":"Manotej","age":20,"city":"Hyderabad","type:"Non-premium"}
]);
db.products.insertMany([
{_id:101,Men:["shirts","Jeans","Trousers"],Brand:"Puma"},
{_id:102,Women:["Kurtas","Dresses","Jeans"],Brand:"Gucci"},
{_id:101,Kids:["Infants","Toys","Sets"],Brand:"Roadster"}
]);
db.seller.insertMany([
{_id:201,"name":"Mohan","age":33,"city":"Chennai"},
{_id:202,"name":"John","age":50,"city":"Indore"},
{_id:203,"name":"Musk","age":28,"city":"Delhi"}
]);
db.admin.insertMany([
{_id:301,"name":"George","age":40,"city":"Paris"},
{_id:302,"name":"Gates","age":55,"city":"USA"}
]);
db.Billing.insertMany([
{_id:401,"Payment":"Yes","order_place":"calcutta",orders:"300"},
{_id:402,"Payment":"No","age":55,"order_place":"Kochi",orders:"1900"}
]);