firesage
Version:
🔥 Extremely High Precision Typescript Wrapper for Firestore Web, Providing Unparalleled Type Safe and Dev Experience
28 lines (25 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeBatch = void 0;
var set_1 = require("./set");
var update_1 = require("./update");
var delete_1 = require("./delete");
var firestore_1 = require("firebase/firestore");
/**
Creates a write batch, used for performing multiple writes as a single atomic operation. The maximum number of writes allowed in a single WriteBatch is 500.
Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data.
@returns
A WriteBatch that can be used to atomically execute multiple writes.
*/
var writeBatch = function (firestore) {
var batch = (0, firestore_1.writeBatch)(
// @ts-expect-error
firestore || (0, firestore_1.getFirestore)());
return Object.freeze({
commit: function () { return batch.commit(); },
set: (0, set_1.setCreator)(batch),
update: (0, update_1.updateCreator)(batch),
delete: (0, delete_1.deleteCreator)(batch),
});
};
exports.writeBatch = writeBatch;