toDataValue()function

toDataValue(value: FirestoreValue, caller: AnyCaller = toDataValue): unknown
ParamType
valueFirestoreValue
The Firestore JSON value to convert. required
    .nullValuenull
readonly
    .booleanValueboolean
readonly
    .integerValuestring
number
readonly
    .doubleValuestring
number
readonly
    .stringValuestring
readonly
    .timestampValuestring
readonly
    .bytesValuestring
readonly
    .referenceValuestring
readonly
    .geoPointValue{ readonly latitude?: number; readonly longitude?: number }
readonly
    .arrayValue{ readonly values?: ImmutableArray<FirestoreValue> }
readonly
    .mapValue{ readonly fields?: FirestoreFields }
readonly
callerAnyCaller
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.

  • integerValue parses to a number, so integers beyond Number.MAX_SAFE_INTEGER lose precision.
  • timestampValue, bytesValue, and referenceValue pass through as their string form; geoPointValue becomes a plain { latitude, longitude } object — wrap the provider in ValidationDBProvider to reject types your schemas don't allow.

Examples

toDataValue({ integerValue: "123" }) // 123