Skip to content

sundogrd/declaration-update

Repository files navigation

Declaration Update

NPM version Downloads Minified size Gzip size

update object using mongodb way, also support comment-json object

👷 Still Working.

Setup via NPM

npm install declaration-update --save

This is a declaration for update a object in Javascript.

// import update from 'react-addons-update';
import { query } from 'declaration-update';

let testStores = {
    _id: 1,
    fruits: [ "apples", "pears", "oranges", "grapes", "bananas" ],
    vegetables: [ "carrots", "celery", "squash", "carrots" ]
}
const change = query(
    testStores,
    {},
    { $pull: { fruits: { $in: [ "apples", "oranges" ] }, vegetables: "carrots" } }
);
console.log(testStores, change)
/*
testStores: {
    "_id" : 1,
    "fruits" : [ "pears", "grapes", "bananas" ],
    "vegetables" : [ "celery", "squash" ]
}
change: [{op: "$pull", key: "vegetables", value: ["carrots", "carrots"]}]
*/

About

update object using mongodb way with immutability

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published