Skip to content

Instantly share code, notes, and snippets.

@smartexpert
Created September 7, 2018 20:23
Show Gist options
  • Save smartexpert/c4166ef216f9e53ad398b710524b9702 to your computer and use it in GitHub Desktop.
Save smartexpert/c4166ef216f9e53ad398b710524b9702 to your computer and use it in GitHub Desktop.
let batch = db.batch
let docToWrite = {
stringField: "StringValue",
dateField: {
startDate: new Date('2018–09–07')
}
}
let setOptions = { merge: true }
batch.set(db.doc('users/user1'), docToWrite, setOptions}
if (change.before.exists && change.before.data().date.endDate.toDate()) {
let docToWrite2 = { field1: "dummyValue" }
batch.update(db.doc('resources/resource1'), docToWrite2)
return batch.commit()
} else {
return batch.commit()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment