unpush()

You can remove an element from an array using with unpush()

Syntax

db.unpush(path,element,callback?)
  • Path; Path is a string, split with dot and required.

  • Element; All types are acceptable and required.

  • Callback; Callback is a function and not required.

Example

db.unpush("user.john.bag","smart phone",(callback) => {
console.log("Removed smart phone")
console.log(callback)
/*
{
    name:"John",
    surname:"Doe",
    age:18,
    bag:[]
}
*/
})

Last updated