Grokking MongoDB
Vote

0% completed

​

Get an Index

Which indexes does the products collection have right now, and does anything use them? Two different commands answer those two questions. These commands build the collection again with two indexes. The drop() call comes first, because a unique index left from earlier work would reject the insert:

db.products.drop() db.products.insertMany([ { name: "Apple", category: "Fruit", price: 1.2 }, { name: "Carrot", category: "Vegetable", price: 0.8 }, { name: "Banana", category: "Fruit", price: 1.1 }, { name: "Broccoli", category: "Vegetable", price: 1.5 },

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content