UNPKG

mockbase

Version:
32 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MockCollectionReference = void 0; const data_converter_1 = require("./data-converter"); const query_1 = require("./query"); class MockCollectionReference extends query_1.MockQuery { constructor(firestore, id, parent, converter) { super(firestore, (parent ? parent.path : "") + "/" + id, converter); this.id = id; this.parent = parent; this.converter = converter; } doc(documentPath) { documentPath = documentPath || this.firestore.nextId(); return this.firestore.doc(this.path + "/" + documentPath).withConverter(this.converter); } add(data) { const doc = this.doc(); return doc.set(data).then(() => doc); } isEqual(other) { return (other instanceof MockCollectionReference && other.firestore === this.firestore && other.path === this.path && other.converter === this.converter); } withConverter(converter) { return new MockCollectionReference(this.firestore, this.id, this.parent && this.parent.withConverter(data_converter_1.DEFAULT_DATA_CONVERTER), converter); } } exports.MockCollectionReference = MockCollectionReference; //# sourceMappingURL=collection-reference.js.map