0.0.2 ā€¢ Published 5 years ago

declaration-update v0.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

Declaration Update

===

NPM version Downloads Minified size Gzip size

update object using mongodb way

šŸ‘· 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"]}]
*/
0.0.2

5 years ago

0.0.1

5 years ago