Firestore update fails when any field (even optional fields) have a null value in the html | بلاگ

Firestore update fails when any field (even optional fields) have a null value in the html

تعرفه تبلیغات در سایت

آخرین مطالب

امکانات وب

Vote count: 0

In the service, I tried both

return this.afs.doc('/users/' + userId).update(user);

and

return this.afs.doc('/users/' + userId).set(user, {merge: true});

and if the user leaves any field blank, the update or set fails with the message:

Error: Function DocumentReference.set() called with invalid data. Unsupported 
field value: undefined (found in field companyName)

If I enter values for all fields, the update works fine.

The interface is:

import * as firebase from 'firebase/app';

export interface Roles {
    subscriber?: boolean;
    editor?: boolean;
    admin?: boolean;
    client?:  boolean;
    delivery?: boolean;
    employee?: boolean;
    superAdmin?: boolean;
    creditHold?: boolean;
}

export interface User {
    email?: string;
    firstName?: string;
    lastName?: string;
    displayName?: string;
    phoneNumber?: string;
    addressLine1?: string;
    addressLine2?: string;
    city?: string;
    state?: string;
    zip?: string;
    countryId?: string;
    companyName?: string;
    companyType?: string;
    userType?: string;
    photoURL?: string;
    masterServicesAgreementId?: string;
    backgroundCheckStatus?: string;
    createdAt?: DateTimeFormat | firebase.firestore.FieldValue;
    lastUpdatedAt?: DateTimeFormat | firebase.firestore.FieldValue;
    uid?: string;
    roles?: Roles;
}

Has anyone seen this?

asked 56 secs ago
Jim Bistis

...
نویسنده : استخدام کار بازدید : 17 تاريخ : چهارشنبه 25 بهمن 1396 ساعت: 5:54