- Now after defining the variable “doc”, we have to save it explicitly, by applying the save command over the data collection.
- Now, if you want to fetch a particular document from the collection, then use its index number. For instance:-
- Indexing in mongoDB
db.collection_name.ensureIndex({key:1});
here key is the file on which we want to perform the indexing and 1 represents ascending order and -1 represents descending order.
0 comments:
Post a Comment