From the course: MongoDB C# Developer Associate Cert Prep
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Creating a single field index in MongoDB - MongoDB Tutorial
From the course: MongoDB C# Developer Associate Cert Prep
Creating a single field index in MongoDB
- Hi, in this video, we will define and create a single field index by using the create index command. We'll also discuss how to enforce uniqueness in the field values by using the unique constraint in an index. Then we'll go over how to identify the indexes that exist for a collection by using getIndexes. Finally, we'll discuss how to determine if a query is using an index. If it is, we'll use explain to determine the index it's using. As the name implies, single field indexes are indexes on a single field. They support queries on a single field and can support sorts on a single field. We can create a single field index for a collection by using the createIndex command. We pass in the field name that we'll include in the index with the order one for ascending. Ascending indexes can be used for both ascending or descending sorts but it's important to specify the order when using compound indexes to perform sorts…
Contents
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Using MongoDB indexes in collections4m 2s
-
(Locked)
Creating a single field index in MongoDB5m 12s
-
(Locked)
Creating a multikey index in MongoDB3m 12s
-
(Locked)
Working with compound indexes in MongoDB6m 22s
-
(Locked)
Deleting MongoDB indexes4m 25s
-
(Locked)
Introduction to MongoDB data modeling review1m 48s
-
(Locked)
-
-
-
-