Multiply a value
Example:
let obj = {nested: {num: 2}};
$mul(obj, {"nested.num": 3})
.then((res) => console.log(res)) // {nested: {num: 6}}
.catch();
Rename a key
Example:
let obj = {nested: {v: "value"}};
$rename(obj, {"nested.v": "key"})
.then((res) => console.log(res)) // {nested: {key: "value"}}
.catch();
Replace a value
Example:
let obj = {nested: {layer1: {}}};
$set(obj, {"nexted.layer1.newSet": "value"})
.then((res) => console.log(res)) // {nested: {layer: {newSet: "value"}}}
.catch();
Remove key/value
Example:
let obj = {nested: {v: "value}};
$unset(obj, {"nested.v": ""})
.then((res) => console.log(res)) // {nested: {}}
.catch();
Method used by all update operators except $rename
to updated nested object values by use of a string - "nested.doc.key"
Examples:
let obj = {nested: {doc: {key: 1}}};
operate(obj, "nested.doc.key", 2, "set");
// obj = {nested: {doc: {key: 2}}}
operate(obj, "nested.doc.key", -1, "inc");
// obj = {nested: {doc: {key: 1}}}
operate(obj, "nested.doc.key", 3, "mul");
// obj = {nested: {doc: {key: 3}}}
operate(obj, "nested.doc.key", "", "unset");
// obj = {nested: {doc: {}}}
object to update
"string.location"
input
operator type string
Generated using TypeDoc
Increment a value or subtract from a value.
Example:
let obj = {nested: {num: 1}}; $inc(obj, {"nested.num": -1}) .then((res) => console.log(res)) // {nested: {num: 0}} .catch();