-
Notifications
You must be signed in to change notification settings - Fork 0
updateLastN(arrayObject,newValues,n,query)
Bhumil Sarvaiya edited this page Aug 31, 2017
·
1 revision
//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.updateLastN(obj,{'age':12},2)
console.log(obj)
//Output
//[ { name: 'abc', type: 'array', age: 20 },
// { name: 'pqr', type: 'string', age: 20 },
// { name: 'xyz', type: 'array', age: 22 },
// { name: 'ghi', type: 'array', age: 12 },
// { name: 'mno', type: 'number', age: 12 } ]
//e.g. 2
daex.updateLastN(obj,{'age':12},2,{'type':'array'})
console.log(obj)
//Output
//[ { name: 'abc', type: 'array', age: 20 },
// { name: 'pqr', type: 'string', age: 20 },
// { name: 'xyz', type: 'array', age: 12 },
// { name: 'ghi', type: 'array', age: 12 },
// { name: 'mno', type: 'number', age: 20 } ]