Mongodb Classroom image

Anil  Bist / Professional / DataBase

 
To post your Question Join Classroom
 
Lesson Topics's No:-  ||
Lessons:-More update operators

More update operator

You can use other operators besides You can use other operators besides  $set  when updating a document. The  $push  operator allows you to push a
value into an array, in this case we will add a new nickname to the  nicknames  array. when updating a document.

db. people.update ( { name: 'Tom' }, { $push: { nicknames: 'Tommy' } } )
//  This adds the string  'Tommy'  into the nicknames array in Tom's document.

 

The $pull  operator is the opposite of $push, you can pull specific items from arrays. 

db. people.update ( { name: 'Tom' }, { $pull: { nicknames:  'Tommy' } } )
//  This removes the string 'Tommy' from the nicknames array in Tom's document.

 

The  $pop  operator allows you to remove the first or the last value from an array. Let's say Tom's document has a property called siblings that has the value  [ 'Marie''Bob' 'Kevin' 'Alex' ]. 

 

 
 
 
image
Anil  Bist

Skills    Mongodb

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)