Files
robot-shop/mongo/catalogue.js

25 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-01-10 16:31:49 +00:00
//
// Products
//
db = db.getSiblingDB('catalogue');
db.products.insertMany([
{sku: 'PB-1', name: 'Positronic Brain', description: 'Highly advanced sentient processing unit', price: 42000, instock: 0, categories: ['components']},
{sku: 'SVO-980', name: 'Servo 980Nm', description: 'Servo actuator with 980Nm of torque. Needs 24V 10A supply', price: 50, instock: 32, categories: ['components']},
{sku: 'ROB-1', name: 'Robbie', description: 'Large mechanical workhorse, crude but effective', price: 1200, instock: 12, categories: ['complete']},
2018-01-25 17:05:28 +00:00
{sku: 'EVE-1', name: 'Eve', description: 'Extraterrestrial Vegetation Evaluator', price: 5000, instock: 10, categories: ['complete']},
{sku: 'HAL-1', name: 'HAL', description: 'Sorry Dave, I cant do that', price: 7500, instock: 2, categories: ['complete']}
2018-01-10 16:31:49 +00:00
]);
// full text index for searching
db.products.createIndex({
name: "text",
description: "text"
});
// unique index for product sku
db.products.createIndex(
{ sku: 1 },
{ unique: true }
);