toDataValue()function
toDataValue(value: FirestoreValue, caller: AnyCaller = toDataValue): unknown
| Param | Type | |
|---|---|---|
value | FirestoreValue | The Firestore JSON value to convert. required |
.nullValue | null | readonly |
.booleanValue | boolean | readonly |
.integerValue | stringnumber | readonly |
.doubleValue | stringnumber | readonly |
.stringValue | string | readonly |
.timestampValue | string | readonly |
.bytesValue | string | readonly |
.referenceValue | string | readonly |
.geoPointValue | { readonly latitude?: number; readonly longitude?: number } | readonly |
.arrayValue | { readonly values?: ImmutableArray<FirestoreValue> } | readonly |
.mapValue | { readonly fields?: FirestoreFields } | readonly |
caller | AnyCaller | Caller function used to attribute thrown errors. Defaults to toDataValue |
| Return | |
|---|---|
unknown | The plain data value. |
| Throws | |
|---|---|
unknown | ValueError if the value has no recognised type. |
Convert a Firestore REST API JSON value back to a data value.
integerValueparses to anumber, so integers beyondNumber.MAX_SAFE_INTEGERlose precision.timestampValue,bytesValue, andreferenceValuepass through as their string form;geoPointValuebecomes a plain{ latitude, longitude }object — wrap the provider inValidationDBProviderto reject types your schemas don't allow.
Examples
toDataValue({ integerValue: "123" }) // 123