unpush()

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

Syntax

db.unpush(path,element,listener?)
  • 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",(err,data) => {
    if(err) return console.log(err.message)
    console.log("Removed smart phone")
    console.log(data)
})
/*
{
    name:"John",
    surname:"Doe",
    age:18,
    bag:[]
}
*/

Last updated