firebase-function
Advanced tools
Comparing version 1.4.97 to 1.4.98
@@ -5,2 +5,3 @@ "use strict"; | ||
const FirestoreDocument_1 = require("./FirestoreDocument"); | ||
const utils_1 = require("../utils"); | ||
class FirestoreCollection { | ||
@@ -14,3 +15,3 @@ firestore; | ||
async addDocument(key, documentValues) { | ||
await this.firestore.collection(this.path.fullPath).doc(key).set(documentValues); | ||
await this.firestore.collection(this.path.fullPath).doc(key).set(utils_1.Flattable.flatten(documentValues)); | ||
} | ||
@@ -17,0 +18,0 @@ getDocument(key) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FirestoreDocument = void 0; | ||
const Flattable_1 = require("./../utils/Flattable"); | ||
const FirestoreCollection_1 = require("./FirestoreCollection"); | ||
@@ -17,3 +18,4 @@ const FirestoreSnapshot_1 = require("./FirestoreSnapshot"); | ||
async setValues(values) { | ||
await this.firestore.doc(this.path.fullPath).update(values); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
await this.firestore.doc(this.path.fullPath).update(Flattable_1.Flattable.flatten(values)); | ||
} | ||
@@ -20,0 +22,0 @@ async snapshot() { |
@@ -0,6 +1,7 @@ | ||
import type { Flatten } from '../utils'; | ||
export declare class FirestoreSnapshot<Values> { | ||
private readonly snapshot; | ||
constructor(snapshot: FirebaseFirestore.DocumentSnapshot<Values>); | ||
constructor(snapshot: FirebaseFirestore.DocumentSnapshot<Flatten<Values>>); | ||
get exists(): boolean; | ||
get data(): Values; | ||
get data(): Flatten<Values>; | ||
} |
@@ -0,1 +1,2 @@ | ||
import { type Flatten } from './../utils/Flattable'; | ||
import { type Firestore as FirestoreInstance, type DocumentSnapshot } from 'firebase/firestore'; | ||
@@ -11,3 +12,3 @@ import type { FirestoreCollection, FirestoreDocument, FirestorePath } from '../firestore'; | ||
setValues(values: FirestoreDocument.ValuesOf<FirestoreScheme>): Promise<void>; | ||
snapshot(): Promise<FirebaseFirestoreSnapshot<FirestoreDocument.ValuesOf<FirestoreScheme>>>; | ||
snapshot(): Promise<FirebaseFirestoreSnapshot<Flatten<FirestoreDocument.ValuesOf<FirestoreScheme>>>>; | ||
} | ||
@@ -14,0 +15,0 @@ export declare class FirebaseFirestoreCollection<FirestoreScheme extends FirestoreCollection<any>> { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FirebaseFirestoreSnapshot = exports.FirebaseFirestoreCollection = exports.FirebaseFirestoreDocument = void 0; | ||
const Flattable_1 = require("./../utils/Flattable"); | ||
const firestore_1 = require("firebase/firestore"); | ||
@@ -18,3 +19,3 @@ class FirebaseFirestoreDocument { | ||
async setValues(values) { | ||
await (0, firestore_1.setDoc)((0, firestore_1.doc)(this.firestoreInstance, this.path.fullPath), values); | ||
await (0, firestore_1.setDoc)((0, firestore_1.doc)(this.firestoreInstance, this.path.fullPath), Flattable_1.Flattable.flatten(values)); | ||
} | ||
@@ -37,3 +38,3 @@ async snapshot() { | ||
async addDocument(key, documentValues) { | ||
await (0, firestore_1.setDoc)((0, firestore_1.doc)(this.firestoreInstance, this.path.appending(key).fullPath), documentValues); | ||
await (0, firestore_1.setDoc)((0, firestore_1.doc)(this.firestoreInstance, this.path.appending(key).fullPath), Flattable_1.Flattable.flatten(documentValues)); | ||
} | ||
@@ -40,0 +41,0 @@ getDocument(key) { |
@@ -66,3 +66,3 @@ "use strict"; | ||
const data = await addDocument(); | ||
(0, testSrc_1.expect)((await baseCollection.getDocument('ouja').snapshot()).data).to.be.deep.equal(data); | ||
(0, testSrc_1.expect)((await baseCollection.getDocument('ouja').snapshot()).data).to.be.deep.equal(src_1.Flattable.flatten(data)); | ||
}); | ||
@@ -82,6 +82,6 @@ it('remove a document', async () => { | ||
await baseCollection.getDocument('ouja').setValues(newData); | ||
(0, testSrc_1.expect)((await baseCollection.getDocument('ouja').snapshot()).data).to.be.deep.equal({ | ||
(0, testSrc_1.expect)((await baseCollection.getDocument('ouja').snapshot()).data).to.be.deep.equal(src_1.Flattable.flatten({ | ||
...data, | ||
...newData | ||
}); | ||
})); | ||
}); | ||
@@ -88,0 +88,0 @@ it('add document to subcollection', async () => { |
{ | ||
"name": "firebase-function", | ||
"version": "1.4.97", | ||
"version": "1.4.98", | ||
"description": "Manages backend api with firebase functions.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
256011
4950