Command Prompt Tutorial

Commands (Cont. 2 )


  •  You can even declare variables which may contain whole set of data.



  •  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:-



  •  You can use a variable to assign value to some other document.





  •   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