-
Notifications
You must be signed in to change notification settings - Fork 0
updateAll(arrayObject,newValues,query)
Bhumil Sarvaiya edited this page Aug 31, 2017
·
2 revisions
//common data
var daex = require('./index')
var obj = [
{
name: 'abc',
type: 'array',
age: 20
},
{
name: 'pqr',
type: 'string',
age: 20
},
{
name: 'xyz',
type: 'array',
age: 22
},
{
name: 'ghi',
type: 'array',
age: 20
},
{
name: 'mno',
type: 'number',
age: 20
}
]
//e.g. 1
daex.updateAll(obj,{'age':12})
console.log(obj)
//Output
//[ { name: 'abc', type: 'array', age: 12 },
// { name: 'pqr', type: 'string', age: 12 },
// { name: 'xyz', type: 'array', age: 12 },
// { name: 'ghi', type: 'array', age: 12 },
// { name: 'mno', type: 'number', age: 12 } ]
//e.g. 2
daex.updateAll(obj,{'age':12},{'type':'array'})
console.log(obj)
//Output
//[ { name: 'abc', type: 'array', age: 12 },
// { name: 'pqr', type: 'string', age: 20 },
// { name: 'xyz', type: 'array', age: 12 },
// { name: 'ghi', type: 'array', age: 12 },
// { name: 'mno', type: 'number', age: 20 } ]
//e.g. 3
daex.updateAll(obj,{'newField':'123'})
console.log(obj)
//Output
//[ { name: 'abc', type: 'array', age: 20, newField: '123' },
// { name: 'pqr', type: 'string', age: 20, newField: '123' },
// { name: 'xyz', type: 'array', age: 22, newField: '123' },
// { name: 'ghi', type: 'array', age: 20, newField: '123' },
// { name: 'mno', type: 'number', age: 20, newField: '123' } ]