UNPKG

@firebase/firestore

Version:

The Cloud Firestore component of the Firebase JS SDK.

79 lines (78 loc) 2.6 kB
/** * @license * Copyright 2017 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { MapValue as ProtoMapValue, Value as ProtoValue } from '../protos/firestore_proto_api'; import { FieldMask } from './field_mask'; import { FieldPath } from './path'; export interface JsonObject<T> { [name: string]: T; } /** * An ObjectValue represents a MapValue in the Firestore Proto and offers the * ability to add and remove fields (via the ObjectValueBuilder). */ export declare class ObjectValue { readonly value: { mapValue: ProtoMapValue; }; constructor(value: { mapValue: ProtoMapValue; }); static empty(): ObjectValue; /** * Returns the value at the given path or null. * * @param path - the path to search * @returns The value at the path or null if the path is not set. */ field(path: FieldPath): ProtoValue | null; /** * Sets the field to the provided value. * * @param path - The field path to set. * @param value - The value to set. */ set(path: FieldPath, value: ProtoValue): void; /** * Sets the provided fields to the provided values. * * @param data - A map of fields to values (or null for deletes). */ setAll(data: Map<FieldPath, ProtoValue | null>): void; /** * Removes the field at the specified path. If there is no field at the * specified path, nothing is changed. * * @param path - The field path to remove. */ delete(path: FieldPath): void; isEqual(other: ObjectValue): boolean; /** * Returns the map that contains the leaf element of `path`. If the parent * entry does not yet exist, or if it is not a map, a new map will be created. */ private getFieldsMap; /** * Modifies `fieldsMap` by adding, replacing or deleting the specified * entries. */ private applyChanges; clone(): ObjectValue; } /** * Returns a FieldMask built from all fields in a MapValue. */ export declare function extractFieldMask(value: ProtoMapValue): FieldMask;