Skip to main content

Posts

Showing posts with the label mongodb interview questions and answers

mongodb switch expression

Syntax:     {$project: {         columnName: {             $switch: {                 branches: [                     {                         case: <your-expression>,                         then: <your-expression>                     }                      ...

mongodb if exists update else insert

In MongoDB , use upsert is equal to true ( upsert: true) for check if items is exists then update else insert. By default upsert  is equal to false. Example as db . Users . update ({ name : 'Anil' }, { name : 'Anil' , age : 30 },               { '$inc' :{ 'sequence' : 1 }}, { 'upsert' : true })

MongoDB update if else

Syntax: db . Users . update ( criteria , update [[, options] , callback ] ); According to MongoDB , ·          A criteria is a query object to find records that need to be updated. ·          Update is the replacement object and the update has multiple options. o     multi : Update all the records that match the query object. o     upsert : If no records match then insert update as a new records. o     raw : returns updated document as json and by default  return false. ·          An option is an options object. ·          Callback is the callback to be run after the records is updated. Example: The matching documents will be replaced                    db . Users . update ({ _id: "1001" }, { na...

71 Best MongoDB Interview Questions and Answers - [MongoDB]

“ MongoDB   is the fastest growing database because it’s provided more security protection mechanisms than others and also more reliable in cloud computing environments. It is secure architecture for your deployment”. It is document oriented database and its store the data in document with   JSON  format. Most Popular 71 Key Questions for MongoDB Interviews. What is MongoDB and Why we use? What's New in MongoDB 3.2? Is MongoDB Support Relationship? Is MongoDB Support Replication? What are journaling in MongoDB? What kind of database is MongoDB? In MongoDB, What is a namespace? In which language MongoDB is written? Do MongoDB databases have tables and schemas? What types of languages use to work with MongoDB? Which are the most powerful features in MongoDB? ...