简体   繁体   中英

Can we listen specific key value changes in firestore angular

getUserEventSummaryE(userId) {

return docData(doc(this.firestore, `/user/${userId}/event_summary/current/`), {idField : 'playing_summary'}).
  pipe(distinctUntilChanged((prev, curr) => _.isEqual(prev, curr)));

}

getUserEventSummaryE should only return document when playing_summary changes but current it returning document data when other than playing_summary key value changes.

Example Document data

{
id: 1,
playing_summary: 'playing',
userbalance: 222,
dob: '2021-05-02'
}

When I change Other than playing_summary then currently changes triggering.

You can't listen to any key-values in the documents, but you can do that on document. It's only triggered when a document is updated.

exports.dbEventsOnUpdate = functions.firestore
.document('events/{eventId}').onUpdate(async (change,context) => {
   
            const eventID = context.params.eventId;
            const newValue = change.after.data();
            const previousValue = change.before.data();
            const titleIsUpdated = newValue.title !== previousValue.title;
    })

You can check this link for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM