Grokking MongoDB
0% completed
Single Field Indexes
Consider a printed staff list sorted by name. You can find Jane Smith without reading every line, list everyone whose name starts with J by reading a few adjacent lines, and read the staff in reverse order by starting at the bottom. The list does not help you find everyone aged 34. A single field index has exactly these abilities and exactly this limit, and the employees collection shows each one:
db.employees.insertMany([ { name: "John Doe", age: 29, department: "HR" }, { name: "Jane Smith", age: 34, department: "Finance" },
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%