Closed kavaro closed 6 years ago
Example test case and proposed fix.
import {struct} from 'superstruct'; import firebase from 'firebase'; import 'firebase/firestore'; import {initFirestorter, Collection, Document} from 'firestorter'; firebase.initializeApp({/*...*/}); initFirestorter({firebase}); export const db = firebase.firestore(); const settings = {timestampsInSnapshots: true}; db.settings(settings); const schema = struct({ name: 'string' }); export class Doc extends Document { constructor(source) { super(source, {schema}); } } async function test() { const collection = new Collection('test', {DocumentClass: Doc}); const doc = await collection.add({name: 'Old name'}); // the update statement below throw's a validation error // // Solution: // in src/Document.js line 346 should be changed // // FROM // // this._validateSchema({ // ...this.data, // fields // }); // // TO // // this._validateSchema({ // ...this.data, // ...fields // }); await doc.update({ name: 'New name' }); } test();
Hi, thanks for reporting this @kavaro ! I've just released an update v0.11.1 which fixes this problem. Cheers!
Example test case and proposed fix.