⚑$pop

Name
Usage Type
Description

$pop

Object

$pop Operator Uses to Remove Last or First Values ​​in Array Types

/* Example Usage */
const model = ...Someone Model

(async () => {

await model.findOneAndUpdate({ name: "Test", age: 20, arr: ["test","test123"] },{ $pop:{ arr:-1 } });
/*
The "arr" value that was ["test","test123"] is now ["test123"]
*/

await model.findOneAndUpdate({ name: "Test", age: 20, arr: ["test","test123"] },{ $pop:{ arr:1 } });
/*
The "arr" value that was ["test","test123"] is now ["test"]
*/

})();

Last updated