Open
Description
as return from _find
and _findAll
we have result array of objects result of datasnapshot.val()
and key of the result is not part of the result set.
I suggest that we create mapper.idAttribute
property on the result set objects array.
_findAll
will look like this:
_findAll (mapper, query, opts) {
query || (query = {})
opts || (opts = {})
const collectionRef = this.getRef(mapper, opts)
return collectionRef.once('value').then((dataSnapshot) => {
const data = dataSnapshot.val()
if (!data) {
return [[], { ref: collectionRef }]
}
const records = []
utils.forOwn(data, (value, key) => {
Object.defineProperty(value, mapper.idAttribute, {
value: key
})
records.push(value)
})
const _query = new Query({
index: {
getAll () {
return records
}
}
})
return [_query.filter(query).run(), { ref: collectionRef }]
})
}
this part is added.
Object.defineProperty(value, mapper.idAttribute, {
value: key
})
Best,
Jovan