Include firebase ID on resource

This commit is contained in:
Garrett Mills 2021-04-10 02:28:35 -05:00
parent e569841356
commit f797cd0e25
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -52,9 +52,17 @@ export class FirebaseResource<T extends FirebaseResourceItem> extends Iterable<T
}) })
} }
protected resolveObject(snapshot: object | null | undefined) { protected resolveObject(snapshot: any | null | undefined) {
if ( !snapshot ) snapshot = {} if ( !snapshot ) snapshot = {}
return Object.values(snapshot)
const returns: T[] = []
for ( const key in snapshot ) {
if ( !snapshot.hasOwnProperty(key) ) continue
snapshot[key].firebaseID = key
returns.push(snapshot[key])
}
return returns
} }
clone(): Iterable<T> { clone(): Iterable<T> {