You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now the cloud function for extension, even with the forceDataSync flag enabled, does not use transactions, so it is still technically possible to have a conflict on multiple concurrent updates to the listened document.
consthandleUpdateDocument=async(before: DocumentSnapshot,after: DocumentSnapshot,timestamp: Number)=>{try{constforceDataSync=config.forceDataSync;if(forceDataSync){constupdatedSnapshot=awaitafter.ref.get();constdata=awaitextract(updatedSnapshot,0);logs.updateIndex(updatedSnapshot.id,data);logs.info('force sync data: execute saveObject');awaitindex.saveObject(data);}else{if(areFieldsUpdated(config,before,after)){logs.debug('Detected a change, execute indexing');constbeforeData: DocumentData=awaitbefore.data();// loop through the after data snapshot to see if any properties were removedconstundefinedAttrs=Object.keys(beforeData).filter(key=>after.get(key)===undefined||after.get(key)===null);logs.debug('undefinedAttrs',undefinedAttrs);// if no attributes were removed, then use partial update of the record.if(undefinedAttrs.length===0){constdata=awaitextract(after,timestamp);logs.updateIndex(after.id,data);logs.debug('execute partialUpdateObject');awaitindex.partialUpdateObject(data,{createIfNotExists: true});}// if an attribute was removed, then use save object of the record.else{constdata=awaitextract(after,0);// delete null value attributes before saving.undefinedAttrs.forEach(attr=>deletedata[attr]);logs.updateIndex(after.id,data);logs.debug('execute saveObject');awaitindex.saveObject(data);}}}}catch(e){logs.error(e);}};
Can a transactional approach be added to resolve multiple concurrent updates conflicts?
The text was updated successfully, but these errors were encountered:
Right now the cloud function for extension, even with the
forceDataSync
flag enabled, does not use transactions, so it is still technically possible to have a conflict on multiple concurrent updates to the listened document.[function code]
Can a transactional approach be added to resolve multiple concurrent updates conflicts?
The text was updated successfully, but these errors were encountered: