react-native-firebase-compiled
Version:
A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto
78 lines (59 loc) • 1.83 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _utils = require("./utils");
var _serialize = require("./utils/serialize");
var _native = require("../../utils/native");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
* @class WriteBatch
*/
class WriteBatch {
constructor(firestore) {
_defineProperty(this, "_firestore", void 0);
_defineProperty(this, "_writes", void 0);
this._firestore = firestore;
this._writes = [];
}
commit() {
return (0, _native.getNativeModule)(this._firestore).documentBatch(this._writes);
}
delete(docRef) {
// TODO: Validation
// validate.isDocumentReference('docRef', docRef);
// validate.isOptionalPrecondition('deleteOptions', deleteOptions);
this._writes.push({
path: docRef.path,
type: 'DELETE'
});
return this;
}
set(docRef, data, options) {
// TODO: Validation
// validate.isDocumentReference('docRef', docRef);
// validate.isDocument('data', data);
// validate.isOptionalPrecondition('options', writeOptions);
const nativeData = (0, _serialize.buildNativeMap)(data);
this._writes.push({
data: nativeData,
options,
path: docRef.path,
type: 'SET'
});
return this;
}
update(docRef, ...args) {
// TODO: Validation
// validate.isDocumentReference('docRef', docRef);
const data = (0, _utils.parseUpdateArgs)(args, 'WriteBatch.update');
this._writes.push({
data: (0, _serialize.buildNativeMap)(data),
path: docRef.path,
type: 'UPDATE'
});
return this;
}
}
exports.default = WriteBatch;
;