skip to Main Content

I referred the example here to filter out duplicate events. I see that the event id contains = as well as / characters. Are the event id base64 encoded? This is creating issues at times as the document path becomes nested collection if a slash / is found in the id. But to my surprise I was not able to base64 decode them.

For example- 2 id which I could track are – LJ79W2cT0inTJbzFEHH/Aw3i10M= and IQUaGYPQpdYZw3mT3dHRca/Q7tU=.

2

Answers


  1. I don’t think there’s any definition of what an event ID in Cloud Functions looks like. You should treat them as opaque strings and not make any assumptions on their contents or the meaning of their contents beyond that if you get the same event ID multiple times, they represent the same event.

    Login or Signup to reply.
  2. You can’t use a Trigger’s EventId as document ID directly, since it can contain forward slashes.

    You should remove the slashes first:

    exports.onGoodsUpdate = functions
        .database
        .ref("goods/{id}")
        .onUpdate((change, context) => {
            const data = change.after.val() as Goods
            const repository = new GoodsReportRepository()
            const report: GoodsReport = {
                id: context.eventId.replace("/", ""),
                groupCode: data.code,
            }
            return repository.save(report)
        })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search