@firebase/firestore

機能

関数説明
関数(アプリ、...)
getFirestore(アプリ)提供されたFirebaseAppに関連付けられている既存のデフォルトFirestoreインスタンスを返します。 。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。
getFirestore(アプリ、データベースID) (ベータ版)指定されたFirebaseAppに関連付けられている既存の名前付きFirestoreインスタンスを返します。 。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。
InitializeFirestore(アプリ、設定、データベースID)指定された設定を使用してFirestoreの新しいインスタンスを初期化します。 getFirestore()を含む他の関数の前にのみ呼び出すことができます。 。カスタム設定が空の場合、この関数はgetFirestore()を呼び出すことと同じです。
関数(firestore, ...)
clearIndexedDbPersistence(ファイアストア)永続ストレージをクリアします。これには、保留中の書き込みとキャッシュされたドキュメントが含まれます。 Firestoreインスタンスが起動していない間 (アプリの終了後、またはアプリの最初の初期化時) に呼び出す必要があります。起動時に、この関数は他の関数 ( initializeFirestore()またはgetFirestore()以外) よりも前に呼び出す必要があります。 ))。 Firestoreインスタンスがまだ実行中の場合、Promise はエラー コードfailed-preconditionで拒否されます。注: clearIndexedDbPersistence()主に、Cloud Firestore を使用する信頼性の高いテストの作成を支援することを目的としています。既存のデータを削除するための効率的なメカニズムを使用しますが、キャッシュされたデータを安全に上書きしたり、回復不能にしたりすることはありません。ユーザー セッション間のキャッシュ データの開示に敏感なアプリケーションの場合は、永続性をまったく有効にしないことを強くお勧めします。
コレクション(firestore, path, pathSegments)指定された絶対パスにあるコレクションを参照するCollectionReferenceインスタンスを取得します。
collectionGroup(firestore, collectionId)指定されたcollectionIdを持つコレクションまたはサブコレクションに含まれるデータベース内のすべてのドキュメントを含む新しいQueryインスタンスを作成して返します。
connectFirestoreEmulator(ファイアストア、ホスト、ポート、オプション) Cloud Firestore エミュレータと通信するようにこのインスタンスを変更します。注: これは、このインスタンスが操作を実行するために使用される前に呼び出す必要があります。
ネットワークを無効にする(ファイアストア)このインスタンスのネットワーク使用を無効にします。これは、 enableNetwork()を介して再度有効にすることができます。 。ネットワークが無効になっている間、スナップショット リスナー、 getDoc()またはgetDocs()呼び出しはキャッシュから結果を返し、ネットワークが復元されるまで書き込み操作はキューに入れられます。
doc(firestore, path, pathSegments)指定された絶対パスにあるドキュメントを参照するDocumentReferenceインスタンスを取得します。
EnableIndexedDbPersistence(firestore,persistenceSettings)可能であれば、永続ストレージを有効にします。失敗すると、 enableIndexedDbPersistence() Promise を拒否するか、例外をスローします。これが失敗する理由はいくつかありますが、エラーのcodeによって特定できます。 * failed-precondition: アプリはすでに別のブラウザー タブで開いています。 * 未実装: ブラウザーはオフライン永続性の実装と互換性がありません。障害が発生した後でも、 Firestoreインスタンスは引き続き使用可能ですが、オフラインの永続性は無効になることに注意してください。注: enableIndexedDbPersistence()他の関数 ( initializeFirestore()を除く) よりも前に呼び出す必要があります。getFirestore() 、またはclearIndexedDbPersistence()永続化は Node.js 環境では使用できません。
EnableMultiTabIndexedDbPersistence(firestore)可能であれば、複数タブの永続ストレージを有効にします。すべてのタブで有効にすると、すべての操作でローカル永続性へのアクセスが共有されます。これには、接続されているすべてのインスタンスにわたるクエリの共有実行や遅延補正されたローカル ドキュメントの更新が含まれます。失敗すると、 enableMultiTabIndexedDbPersistence() Promise を拒否するか、例外をスローします。これが失敗する理由はいくつかありますが、エラーのcodeによって特定できます。 * failed-precondition: アプリはすでに別のブラウザー タブで開かれており、マルチタブが有効になっていません。 * 未実装: ブラウザーはオフライン永続性の実装と互換性がありません。障害が発生した後でも、 Firestoreインスタンスは引き続き使用可能ですが、オフラインの永続性は無効になることに注意してください。
イネーブルネットワーク(ファイアストア) disableNetwork()を事前に呼び出した後、このFirestoreインスタンスのネットワークの使用を再度有効にします。
getPersistentCacheIndexManager(firestore)指定されたFirestoreオブジェクトによって使用される PersistentCache Index Manager を返します。 PersistentCacheIndexManagerインスタンス、またはローカル永続ストレージが使用されていない場合はnull
loadBundle(firestore、bundleData) Firestore バンドルをローカル キャッシュにロードします。
namedQuery(firestore, 名前)指定された名前で識別されるローカル キャッシュから Firestoreクエリを読み取ります。名前付きクエリはサーバー側で (結果のドキュメントとともに) バンドルにパッケージ化され、 loadBundleを使用してローカル キャッシュにロードされます。ローカル キャッシュに入ったら、このメソッドを使用して名前でクエリを抽出します。
onSnapshotsInSync(ファイアストア、オブザーバー)同期スナップショット イベントのリスナーをアタッチします。同期スナップショット イベントは、サーバーで生成された単一の変更が複数のリスナーに影響を与える場合でも、特定の変更の影響を受けるすべてのリスナーが起動したことを示します。注: 同期スナップショット イベントは、リスナーが相互に同期していることを示すだけであり、それらのスナップショットがサーバーと同期しているかどうかには関係しません。個々のリスナーで SnapshotMetadata を使用して、スナップショットがキャッシュからのものかサーバーからのものかを判断します。
onSnapshotsInSync(firestore、onSync)同期スナップショット イベントのリスナーをアタッチします。同期スナップショット イベントは、サーバーで生成された単一の変更が複数のリスナーに影響を与える場合でも、特定の変更の影響を受けるすべてのリスナーが起動したことを示します。注: 同期スナップショット イベントは、リスナーが相互に同期していることを示すだけであり、それらのスナップショットがサーバーと同期しているかどうかには関係しません。個々のリスナーでSnapshotMetadataを使用して、スナップショットがキャッシュからのものかサーバーからのものかを判断します。
runTransaction(firestore、updateFunction、オプション)指定されたupdateFunctionを実行し、トランザクション内で適用された変更をコミットしようとします。トランザクション内で読み取られたドキュメントが変更された場合、Cloud Firestore はupdateFunctionを再試行します。 5 回試行してもコミットに失敗すると、トランザクションは失敗します。 1 つのトランザクションで許可される書き込みの最大数は 500 です。
setIndexConfiguration(firestore, 構成) (ベータ)ローカル クエリ実行用のインデックス作成を構成します。以前のインデックス構成はすべて上書きされます。インデックス構成が永続化されると、 Promise解決されます。インデックス エントリ自体は非同期的に作成されます。インデックスがまだ利用できない場合でも、インデックス作成が必要なクエリを引き続き使用できます。インデックス エントリが書き込まれると、インデックスを使用してクエリの実行が自動的に開始されます。インデックスは IndexedDb 永続性でのみサポートされます。 IndexedDb が有効になっていない場合、インデックス構成は無視されます。
setIndexConfiguration(firestore, json) (ベータ)ローカル クエリ実行用のインデックス作成を構成します。以前のインデックス構成はすべて上書きされます。インデックス構成が永続化されると、 Promise解決されます。インデックス エントリ自体は非同期的に作成されます。インデックスがまだ利用できない場合でも、インデックス作成が必要なクエリを引き続き使用できます。インデックス エントリが書き込まれると、インデックスを使用してクエリの実行が自動的に開始されます。インデックスは IndexedDb 永続性でのみサポートされます。インデックス構成を設定する前に、 enableIndexedDbPersistence()またはenableMultiTabIndexedDbPersistence()を呼び出します。 IndexedDb が有効になっていない場合、インデックス構成は無視されます。このメソッドは、Firebase CLI ( firebase firestore:indexes ) によってエクスポートされた JSON 形式を受け入れます。 JSON 形式が無効な場合、このメソッドはエラーをスローします。
終了(ファイアストア)提供されたFirestoreインスタンスを終了します。 terminate()を呼び出した後は、 clearIndexedDbPersistence()関数のみを使用できます。他の関数はFirestoreErrorをスローします。終了後に再起動するには、 getFirestore()を使用して FirebaseFirestore の新しいインスタンスを作成します。終了によって保留中の書き込みはキャンセルされず、サーバーからの応答を待っている Promise は解決されません。永続性を有効にしている場合は、次回このインスタンスを起動したときに、サーバーへの書き込みの送信が再開されます。注: 通常の状況では、 terminate()を呼び出す必要はありません。この関数は、このインスタンスにすべてのリソースを強制的に解放する場合、またはテスト実行の間にすべてのローカル状態が確実に破棄されるようにするために、 clearIndexedDbPersistence()と組み合わせて使用​​する場合にのみ役立ちます。
waitForPendingWrites(ファイアストア)アクティブ ユーザーの現在保留中の書き込みがすべてバックエンドによって確認されるまで待機します。未処理の書き込みがない場合、返された Promise はすぐに解決されます。それ以外の場合、Promise は以前に発行されたすべての書き込み (前のアプリ セッションで書き込まれた書き込みを含む) を待機しますが、関数の呼び出し後に追加された書き込みは待機しません。追加の書き込みを待機する場合は、 waitForPendingWrites()を再度呼び出します。未処理のwaitForPendingWrites() Promise は、ユーザーの変更中に拒否されます。
writeBatch(ファイアストア)複数の書き込みを 1 つのアトミック操作として実行するために使用される書き込みバッチを作成します。 1 つのWriteBatchで許可される書き込みの最大数は 500 です。トランザクションとは異なり、書き込みバッチはオフラインで保持されるため、読み取りデータに対して書き込みを条件付ける必要がない場合に適しています。
関数()
カウント()クエリの結果セット内のドキュメントの数を計算するために使用できる AggregateField オブジェクトを作成します。
削除フィールド() {merge: true}を指定したupdateDoc()またはsetDoc()で使用してフィールドを削除対象としてマークするためのセンチネルを返します。
ドキュメントID()ドキュメントの ID を参照する特別なセンチネルFieldPathを返します。これをクエリで使用して、ドキュメント ID で並べ替えたりフィルター処理したりできます。
getFirestore()デフォルトのFirebaseAppに関連付けられている既存のデフォルトFirestoreインスタンスを返します。 。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。
MemoryEagerGarbageCollector() MemoryEagerGarbageCollectorのインスタンスを作成します。特に明示的に指定されていない限り、これはデフォルトのガベージ コレクターでもあります。
persistentMultipleTabManager() PersistentMultipleTabManagerのインスタンスを作成します。
サーバータイムスタンプ()サーバーが生成したタイムスタンプを書き込まれたデータに含めるためにsetDoc()またはupdateDoc()で使用されるセンチネルを返します。
関数(データベースID, ...)
getFirestore(データベースID) (ベータ版)デフォルトのFirebaseAppに関連付けられている既存の名前付きFirestoreインスタンスを返します。 。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。
関数(要素, ...)
arrayRemove(要素) setDoc()で使用できる特別な値、またはサーバー上にすでに存在する配列値から指定された要素を削除するようにサーバーに指示する特別な値を返します。指定された各要素のすべてのインスタンスが配列から削除されます。変更されるフィールドがまだ配列でない場合は、空の配列で上書きされます。
arrayUnion(要素) setDoc()またはupdateDoc()で使用できる特別な値を返し、指定された要素とサーバー上にすでに存在する配列値を結合するようにサーバーに指示します。配列内にまだ存在しない指定された各要素が最後に追加されます。変更されるフィールドがまだ配列でない場合は、指定された要素を正確に含む配列で上書きされます。
関数(フィールド, ...)
平均(フィールド)クエリの結果セット内のドキュメントの範囲にわたる指定されたフィールドの平均を計算するために使用できる AggregateField オブジェクトを作成します。
合計(フィールド)クエリの結果セット内のドキュメント範囲にわたる指定されたフィールドの合計を計算するために使用できる AggregateField オブジェクトを作成します。
関数(フィールドパス, ...)
orderBy(フィールドパス, 方向Str)指定されたフィールドによってクエリ結果を並べ替えるQueryOrderByConstraintを作成します。オプションで昇順ではなく降順で並べ替えることもできます。注: 指定されたフィールドを含まないドキュメントはクエリ結果には表示されません。
where(フィールドパス、opStr、値)ドキュメントに指定されたフィールドが含まれている必要があり、値が指定されたリレーション制約を満たす必要があることを強制するQueryFieldFilterConstraintを作成します。
関数(フィールド値, ...)
endAt(フィールド値)クエリの順序を基準にして、指定されたフィールドで終了するように結果セットを変更するQueryEndAtConstraintを作成します。フィールド値の順序は、クエリの order by 句の順序と一致する必要があります。
endBefore(フィールド値)クエリの順序を基準にして、指定されたフィールドの前で終了するように結果セットを変更するQueryEndAtConstraintを作成します。フィールド値の順序は、クエリの order by 句の順序と一致する必要があります。
startAfter(フィールド値)クエリの順序に関連して、指定されたフィールドの後に開始するように結果セットを変更するQueryStartAtConstraintを作成します。フィールド値の順序は、クエリの order by 句の順序と一致する必要があります。
startAt(フィールド値)クエリの順序に相対して、指定されたフィールドから開始するように結果セットを変更するQueryStartAtConstraintを作成します。フィールド値の順序は、クエリの order by 句の順序と一致する必要があります。
関数(インデックスマネージャー, ...)
deleteAllPersistentCacheIndexes(indexManager)すべての永続キャッシュ インデックスを削除します。この関数は、廃止予定であるsetIndexConfiguration()によって生成されたインデックスも削除することに注意してください。
disablePersistentCacheIndexAutoCreation(indexManager)ローカルクエリ実行用の永続キャッシュインデックスの自動作成を停止します。 enablePersistentCacheIndexAutoCreation()を呼び出して作成されたインデックスは引き続き有効です。
EnablePersistentCacheIndexAutoCreation(indexManager)キャッシュ インデックスがパフォーマンスの向上に役立つと SDK が判断した場合、SDK がローカル クエリ実行用の永続キャッシュ インデックスを自動的に作成できるようにします。この機能はデフォルトでは無効になっています。
関数(左, ...)
aggregateFieldEqual(左, 右) 2 つの 'AggregateField を比較します` 等価性のインスタンス。
aggregateQuerySnapshotEqual(左、右) 2 つのAggregateQuerySnapshotインスタンスが等しいかどうかを比較します。 2 つのAggregateQuerySnapshotインスタンスは、同じデータを比較する基礎となるクエリがある場合、「等しい」とみなされます。
queryEqual(左、右)指定されたクエリが同じコレクションを指し、同じ制約を適用する場合は true を返します。
refEqual(左、右)指定された参照が等しい場合は true を返します。
スナップショット等しい(左、右)提供されたスナップショットが等しい場合は true を返します。
関数(制限, ...)
限界(限界)最初に一致したドキュメントのみを返すQueryLimitConstraintを作成します。
最後までの制限(制限)最後に一致したドキュメントのみを返すQueryLimitConstraintを作成します。 limitToLastクエリには少なくとも 1 つのorderBy句を指定する必要があります。指定しないと、実行中に例外がスローされます。
関数(ログレベル, ...)
setLogLevel(logLevel) Cloud Firestore ログの詳細度(デバッグ、エラー、またはサイレント)を設定します。
関数(n, ...)
増分(n) setDoc()またはupdateDoc()で使用できる特別な値を返し、フィールドの現在の値を指定された値だけインクリメントするようにサーバーに指示します。オペランドまたは現在のフィールド値のいずれかが浮動小数点精度を使用する場合、すべての算術演算は IEEE 754 セマンティクスに従います。両方の値が整数の場合、JavaScript の安全な数値範囲 ( Number.MIN_SAFE_INTEGERからNumber.MAX_SAFE_INTEGER ) の外にある値も精度が失われる可能性があります。さらに、Firestore バックエンドによって処理されると、すべての整数演算は -2^63 から 2^63-1 までの範囲に制限されます。現在のフィールド値がタイプnumberでない場合、またはフィールドがまだ存在しない場合、変換によりフィールドが指定された値に設定されます。
関数(クエリ、...)
getAggregateFromServer(クエリ、aggregateSpec)実際にドキュメントをダウンロードせずに、指定されたクエリの結果セット内のドキュメントに対して指定された集計を計算します。この関数を使用して集計を実行すると、ドキュメントのデータではなく最終的な集計値のみがダウンロードされるため、効率的です。この関数は、結果セットが全体をダウンロードできないほど大きい (数千のドキュメント) 場合に、ドキュメントの集約を実行できます。サーバーから受信した結果は、ローカル状態を考慮せずに、変更されずに表示されます。つまり、ローカル キャッシュ内のドキュメントは考慮されず、サーバーとまだ同期されていないローカルの変更も考慮されません。以前にダウンロードされた結果がある場合でも、それは使用されません。この関数を呼び出すたびに、必ずサーバーとの往復が必要になります。
getCountFromServer(クエリ)実際にドキュメントをダウンロードせずに、指定されたクエリの結果セット内のドキュメントの数を計算します。この関数を使用してドキュメントをカウントすると、ドキュメントのデータではなく最終的なカウントのみがダウンロードされるため、効率的です。この関数は、結果セットが全体をダウンロードできないほど大きい (数千のドキュメント) 場合にドキュメントをカウントできます。サーバーから受信した結果は、ローカル状態を考慮せずに、変更されずに表示されます。つまり、ローカル キャッシュ内のドキュメントは考慮されず、サーバーとまだ同期されていないローカルの変更も考慮されません。以前にダウンロードされた結果がある場合でも、それは使用されません。この関数を呼び出すたびに、必ずサーバーとの往復が必要になります。
getDocs(クエリ)クエリを実行し、結果をQuerySnapshotとして返します。注: getDocs()サーバーからのデータを待機することで、可能な限り最新のデータを提供しようとしますが、オフラインでサーバーにアクセスできない場合は、キャッシュされたデータが返されるか、失敗する可能性があります。この動作を指定するには、 getDocsFromCache()またはgetDocsFromServer()を呼び出します。
getDocsFromCache(クエリ)クエリを実行し、結果をキャッシュからQuerySnapshotとして返します。クエリに一致するドキュメントが現在キャッシュされていない場合は、空の結果セットを返します。
getDocsFromServer(クエリ)クエリを実行し、結果をサーバーからQuerySnapshotとして返します。ネットワークが利用できない場合はエラーを返します。
onSnapshot(クエリ、オブザーバー) QuerySnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。リスナーは、 onSnapshot呼び出されたときに返される関数を呼び出すことでキャンセルできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(クエリ、オプション、オブザーバー) QuerySnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。リスナーは、 onSnapshot呼び出されたときに返される関数を呼び出すことでキャンセルできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(クエリ、onNext、onError、onCompletion) QuerySnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。リスナーは、 onSnapshot呼び出されたときに返される関数を呼び出すことでキャンセルできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(クエリ、オプション、onNext、onError、onCompletion) QuerySnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。リスナーは、 onSnapshot呼び出されたときに返される関数を呼び出すことでキャンセルできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
query(クエリ、compositeFilter、queryConstraints)追加のクエリ制約も含めるように拡張されたQueryの新しい不変インスタンスを作成します。
クエリ(クエリ、クエリ制約)追加のクエリ制約も含めるように拡張されたQueryの新しい不変インスタンスを作成します。
関数(クエリ制約, ...)
and(クエリ制約)指定されたフィルター制約を組み合わせた新しいQueryCompositeFilterConstraintを作成します。結合フィルタには、指定されたフィルタをすべて満たす場合にドキュメントが含まれます。
or(クエリ制約)指定されたフィルター制約の論理和である新しいQueryCompositeFilterConstraintを作成します。論理和フィルタには、指定されたフィルタのいずれかを満たしている場合にドキュメントが含まれます。
関数(参照、...)
addDoc(参照、データ)指定されたデータを使用して新しいドキュメントを指定されたCollectionReferenceに追加し、ドキュメント ID を自動的に割り当てます。
コレクション(参照、パス、パスセグメント)指定された相対パスにあるreferenceのサブコレクションを参照するCollectionReferenceインスタンスを取得します。
コレクション(参照、パス、パスセグメント)指定された相対パスにあるreferenceのサブコレクションを参照するCollectionReferenceインスタンスを取得します。
deleteDoc(参照)指定されたDocumentReferenceによって参照されるドキュメントを削除します。
doc(参照、パス、パスセグメント)指定された相対パスにあるreference内のドキュメントを参照するDocumentReferenceインスタンスを取得します。パスが指定されていない場合、返されるDocumentReferenceには自動生成された一意の ID が使用されます。
doc(参照、パス、パスセグメント)指定された相対パスにあるreference内のドキュメントを参照するDocumentReferenceインスタンスを取得します。
getDoc(参照)このDocumentReferenceによって参照されるドキュメントを読み取ります。注: getDoc()サーバーからのデータを待機することで、可能な限り最新のデータを提供しようとしますが、オフラインでサーバーにアクセスできない場合は、キャッシュされたデータが返されるか、失敗する可能性があります。この動作を指定するには、 getDocFromCache()またはgetDocFromServer()を呼び出します。
getDocFromCache(参照)このDocumentReferenceによって参照されるドキュメントをキャッシュから読み取ります。ドキュメントが現在キャッシュされていない場合は、エラーを返します。
getDocFromServer(参照)このDocumentReferenceによって参照されるドキュメントをサーバーから読み取ります。ネットワークが利用できない場合はエラーを返します。
onSnapshot(リファレンス、オブザーバー) DocumentSnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(参照、オプション、オブザーバー) DocumentSnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(参照、onNext、onError、onCompletion) DocumentSnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
onSnapshot(参照、オプション、onNext、onError、onCompletion) DocumentSnapshotイベントのリスナーをアタッチします。個別のonNextおよびonErrorコールバックを渡すことも、 nextおよびerrorコールバックを含む単一のオブザーバー オブジェクトを渡すこともできます。注: onCompletionコールバックを提供できますが、スナップショット ストリームは終わりがないため、呼び出されることはありません。
setDoc(参照、データ)このDocumentReferenceによって参照されるドキュメントに書き込みます。ドキュメントがまだ存在しない場合は作成されます。
setDoc(参照、データ、オプション)指定されたDocumentReferenceによって参照されるドキュメントに書き込みます。ドキュメントがまだ存在しない場合は作成されます。 mergeまたはmergeFieldsを指定すると、指定されたデータを既存のドキュメントにマージできます。
updateDoc(参照、データ)指定されたDocumentReferenceによって参照されるドキュメント内のフィールドを更新します。存在しないドキュメントに適用すると、更新は失敗します。
updateDoc(参照、フィールド、値、moreFieldsAndValues)指定されたDocumentReferenceによって参照されるドキュメント内のフィールドを更新します。存在しないドキュメントに適用すると、更新は失敗します。ネストされたフィールドは、ドット区切りのフィールド パス文字列を指定するか、 FieldPathオブジェクトを指定することによって更新できます。
機能(設定など)
メモリローカルキャッシュ(設定) MemoryLocalCacheのインスタンスを作成します。インスタンスをFirestoreSettings.cacheに設定して、どのキャッシュ レイヤーを使用するかを SDK に指示できます。
メモリLruGarbageCollector(設定) MemoryLruGarbageCollectorのインスタンスを作成します。ターゲット サイズは設定パラメータの一部として指定できます。キャッシュ サイズが指定されたサイズを超えると、コレクターはドキュメントの削除を開始します。デフォルトのキャッシュ サイズは 40MB (40 * 1024 * 1024 バイト) です。
永続ローカルキャッシュ(設定) PersistentLocalCacheのインスタンスを作成します。インスタンスをFirestoreSettings.cacheに設定して、どのキャッシュ レイヤーを使用するかを SDK に指示できます。永続キャッシュは Node.js 環境では使用できません。
永続的SingleTabManager(設定) PersistentSingleTabManagerのインスタンスを作成します。
関数(スナップショットなど)
endAt(スナップショット)指定されたドキュメント (両端を含む) で終了するように結果セットを変更するQueryEndAtConstraintを作成します。終了位置はクエリの順序に相対します。ドキュメントには、クエリの orderBy で指定されたすべてのフィールドが含まれている必要があります。
endBefore(スナップショット)指定されたドキュメントの前で終了するように結果セットを変更するQueryEndAtConstraintを作成します (排他的)。終了位置はクエリの順序に相対します。ドキュメントには、クエリの orderBy で指定されたすべてのフィールドが含まれている必要があります。
startAfter(スナップショット)指定されたドキュメントの後に開始するように結果セットを変更するQueryStartAtConstraintを作成します (排他的)。開始位置はクエリの順序に相対します。ドキュメントには、クエリの orderBy で指定されたすべてのフィールドが含まれている必要があります。
startAt(スナップショット)指定されたドキュメント (両端を含む) から開始するように結果セットを変更するQueryStartAtConstraintを作成します。開始位置はクエリの順序に相対します。ドキュメントには、このクエリのorderByで提供されるすべてのフィールドが含まれている必要があります。

クラス

クラス説明
集計フィールドFirestore によって実行できる集計を表します。
集計クエリスナップショット集計クエリの実行結果。
バイトバイト配列を表す不変オブジェクト。
コレクションリファレンスCollectionReferenceオブジェクトは、ドキュメントの追加、ドキュメント参照の取得、およびドキュメントのクエリ ( query()を使用) に使用できます。 )。
ドキュメントリファレンスDocumentReference Firestore データベース内のドキュメントの場所を参照し、その場所の書き込み、読み取り、またはリスニングに使用できます。参照された場所にあるドキュメントは存在する場合もあれば、存在しない場合もあります。
ドキュメントスナップショットDocumentSnapshotには、Firestore データベース内のドキュメントから読み取られたデータが含まれています。 .data()または.get(<field>)を使用してデータを抽出し、特定のフィールドを取得できます。存在しないドキュメントを指すDocumentSnapshotの場合、データ アクセスはすべて「未定義」を返します。 exists()メソッドを使用すると、ドキュメントの存在を明示的に確認できます。
フィールドパスFieldPathドキュメント内のフィールドを参照します。パスは、単一のフィールド名 (ドキュメント内の最上位フィールドを参照) またはフィールド名のリスト (ドキュメント内のネストされたフィールドを参照) で構成されます。フィールド名を指定してFieldPathを作成します。複数のフィールド名が指定された場合、パスはドキュメント内のネストされたフィールドを指します。
フィールド値set()またはupdate()を使用してドキュメント フィールドを書き込むときに使用できるセンチネル値。
ファイヤーストアCloud Firestore サービス インターフェイス。このコンストラクターを直接呼び出さないでください。代わりに、 getFirestore()を使用してください。
FirestoreエラーFirestore オペレーションによって返されたエラー。
ジオポイントFirestore の地理的位置を表す不変オブジェクト。位置は緯度と経度のペアとして表されます。緯度の値の範囲は [-90, 90] です。経度の値の範囲は [-180, 180] です。
ロードバンドルタスクFirestore バンドルをロードするタスクを表します。バンドルの読み込みの進行状況、タスクの完了およびエラー イベントが表示されます。この API はPromise<LoadBundleTaskProgress>と互換性があります。
PersistentCacheIndexManagerローカル クエリの実行に使用される永続キャッシュ インデックスを構成するためのPersistentCacheIndexManager使用するには、 getPersistentCacheIndexManager()を呼び出してインスタンスを取得します。
クエリQueryは、読んだり聞いたりできるクエリを指します。フィルターや順序を追加して、洗練されたQueryオブジェクトを構築することもできます。
クエリ複合フィルタ制約QueryCompositeFilterConstraintは、複数のQueryFieldFilterConstraintの論理 OR または AND を実行することにより、Firestore クエリによって返されるドキュメントのセットを絞り込むために使用されます。 s またはQueryCompositeFilterConstraint s. QueryCompositeFilterConstraint、 or()またはand()を呼び出すことによって作成され、その後query()に渡されて、 QueryCompositeFilterConstraintも含まれる新しいクエリ インスタンスを作成できます。
クエリ制約QueryConstraintは、Firestore クエリによって返されるドキュメントのセットを絞り込むために使用されます。 QueryConstraintwhere()を呼び出すことによって作成されますorderBy()startAt()startAfter()endBefore()endAt()制限()limitToLast() を実行し、このQueryConstraintも含む新しいクエリ インスタンスを作成するためにquery()に渡すことができます。
クエリドキュメントスナップショットQueryDocumentSnapshotには、クエリの一部として Firestore データベース内のドキュメントから読み取られたデータが含まれています。ドキュメントは存在することが保証されており、そのデータを.data()または.get(<field>)で抽出して特定のフィールドを取得できます。 QueryDocumentSnapshotは、 DocumentSnapshotと同じ API サーフェスを提供します。クエリ結果には既存のドキュメントのみが含まれるため、 existsプロパティは常に true になり、 data()は '未定義' を返すことはありません。
クエリ終了アット制約QueryEndAtConstraintは、Firestore クエリによって返される結果セットの末尾からドキュメントを除外するために使用されます。 QueryEndAtConstraintは、 endAt()またはendBefore()を呼び出すことによって作成され、その後query()に渡されて、このQueryEndAtConstraintも含まれる新しいクエリ インスタンスを作成できます。
クエリフィールドフィルター制約QueryFieldFilterConstraintは、1 つ以上のドキュメント フィールドでフィルタリングすることにより、Firestore クエリによって返されるドキュメントのセットを絞り込むために使用されます。 QueryFieldFilterConstraintwhere()を呼び出すことによって作成され、その後query()に渡されて、このQueryFieldFilterConstraintも含まれる新しいクエリ インスタンスを作成できます。
クエリ制限制約QueryLimitConstraintは、Firestore クエリによって返されるドキュメントの数を制限するために使用されます。 QueryLimitConstraintは、 limit()またはlimitToLast()を呼び出すことによって作成され、その後query()に渡されて、このQueryLimitConstraintも含まれる新しいクエリ インスタンスを作成できます。
QueryOrderByConstraint QueryOrderByConstraintは、Firestore クエリによって返されたドキュメントのセットを並べ替えるために使用されます。 QueryOrderByConstraint sは、 Orderby()を呼び出すことによって作成され、その後、 Query()に渡すことができ、このQueryOrderByConstraintも含まれる新しいQueryインスタンスを作成できます。注:Orderbyフィールドを含まないドキュメントは、クエリ結果には存在しません。
querysnapshot QuerySnapshotは、クエリの結果を表すゼロ以上のDocumentSnapshotオブジェクトが含まれています。ドキュメントは、 docsプロパティを介して配列としてアクセスするか、 forEachメソッドを使用して列挙されています。ドキュメントの数は、 emptysizeプロパティを介して決定できます。
querystartatconstraint QueryStartAtConstraintは、Firestoreクエリによって返された結果セットの開始からドキュメントを除外するために使用されます。 QueryStartAtConstraint sは、 startat()またはstartafter()を呼び出すことによって作成され、 query()に渡すことができ、このQueryStartAtConstraintも含まれる新しいqueryインスタンスを作成できます。
Snapshotmetadataスナップショットについてのメタデータ、スナップショットの状態を説明します。
タイムスタンプTimestamp UTCエポック時間のナノ秒解像度で数秒および秒の分数として表される、任意のタイムゾーンまたはカレンダーに依存しない時点を表します。これは、グレゴリオ暦を1年に逆に拡張する繁殖グレゴリオ暦を使用してエンコードされています。すべての分が60秒の長さであると仮定してエンコードされます。つまり、跳躍秒は「スミア」されているため、解釈には跳躍2番目のテーブルが必要ありません。範囲は、0001-01-01T00:00:00Zから9999-12-31T23:59:59.999999999zです。例とその他の仕様については、タイムスタンプの定義を参照してください
取引トランザクションへの参照。トランザクションのupdateFunctionに渡されたTransactionオブジェクトは、トランザクションコンテキスト内でデータを読み取りおよび書き込む方法を提供します。 runtransaction()を参照してください
書き込みバッチ単一の原子単位として複数の書き込みを実行するために使用される書き込みバッチ。 WriteBatchオブジェクトは、 writebatch()を呼び出すことで取得できます。書き込みバッチに書き込みを追加する方法を提供します。 writebatch.commit()が呼び出されるまで(または局所的に見える)、書かれたものはありません。

インターフェース

インターフェース説明
aggregatespec集約のセットとそのエイリアスを指定します。
DocumentChange DocumentChangeは、クエリに一致するドキュメントの変更を表します。影響を受けるドキュメントと、発生した変更の種類が含まれています。
documentdataドキュメントデータ( setdoc()で使用するため)値にマッピングされたフィールドで構成されています。
実験的にongpollingoptions長時間中毒の場合にSDKの基礎となるネットワークトランスポート(WebChannel)を構成するオプション。注:このインターフェイスは「実験的」であり、変更される場合があります。 FirestoreSettings.experimentalAutoDetectLongPollingFirestoreSettings.experimentalForceLongPolling 、およびFirestoreSettings.experimentalLongPollingOptionsを参照してください。
FirestoredAtaConverter withConverter()で使用されるコンバーターは、タイプAppModelTypeのユーザーオブジェクトをタイプDbModelTypeのFirestoreデータに変換します。コンバーターを使用すると、Firestoreからオブジェクトを保存および取得するときに、一般的なタイプの引数を指定できます。これに関連して、「AppModel」は、アプリケーションで使用されるクラスで、関連情報と機能をパッケージ化します。このようなクラスは、たとえば、複雑でネストされたデータ型を持つプロパティ、メモ化に使用されるプロパティ、Firestore( symbolbigintなど)でサポートされていないタイプのプロパティ、および複合操作を実行するヘルパー関数を持つことができます。このようなクラスは、Firestoreデータベースに保管するのに適していません。代わりに、そのようなクラスのインスタンスは、他のPOJOまたはPOJOの配列内に潜在的にネストされる潜在的に原始的な特性を備えた「プレーン古いJavaScriptオブジェクト」(POJO)に変換する必要があります。これに関連して、このタイプは「dbmodel」と呼ばれ、ファイヤーストアに持続するのに適したオブジェクトです。便利なため、アプリケーションはFirestoreDataConverterを実装し、ConverterをDocumentReferenceQueryなどのFirestoreオブジェクトに登録して、Firestoreに保存するときにAppModel DbModelに自動的に変換し、Firestoreから取得するときにDbModelAppModelに変換します。
Firestoresettings Cloud Firestoreインスタンスのカスタム構成を指定します。他の方法を呼び出す前に、これらを設定する必要があります。
索引(ベータ)ファイヤーストアインデックスのSDK定義。
IndexConfiguration (ベータ)ローカルクエリの実行をスピードアップするためのファイヤーストアインデックスのリスト。インデックス定義の形式の説明については、 JSON形式を参照してください。
インデックスフィールド(ベータ)インデックス構成の単一のフィールド要素。
loadbundletaskprogressバンドルの読み込みによる進行状況の更新または最終状態を表します。
MemoryCachesettings MemoryLocalCacheインスタンスを構成するための設定オブジェクト。
MemoryeAgergarBageCollectorゴミコレクターは、アクティブなクエリの一部ではなく、それらに局所的な突然変異がない場合はいつでもドキュメントを削除します。このコレクターは、オフラインクエリやキャッシュへの直接クエリのためにドキュメントがキャッシュされないリスクがあるため、SDKからの最低メモリフットプリントを確保しようとします。工場関数を使用して、このコレクターのインスタンスを作成します。
MemoryLocalCache SDKにメモリ内キャッシュを提供します。これは、明示的に構成されていない限り、デフォルトのキャッシュです。使用するには、工場関数を使用してインスタンスを作成し、インスタンスをFirestoreSettings.cacheに設定し、設定オブジェクトを使用してinitializeFirestoreを呼び出します。
MemoryLrugarBageCollectorガベージコレクターは、複数のバッチで最も使用されていないドキュメントを削除します。このコレクターはターゲットサイズで構成されており、キャッシュされたドキュメントがターゲットサイズを超える場合にのみコレクションを実行します。メモリフットプリントが大きくなるリスクがあるため、同じクエリまたはドキュメントに対してバックエンドの繰り返しを繰り返すことを避けます。工場関数を使用して、このコレクターのインスタンスを作成します。
PersistencesEttings Firestoreの永続性を構成するためにenableIndexedDbPersistence()に渡すことができる設定。 node.js環境では永続性を使用することはできません。
PersistentCachesettings PersistentLocalCacheインスタンスを構成する設定オブジェクト。 node.js環境では、永続的なキャッシュを使用できません。
PersistentLocalCache indexedDBに裏打ちされた永続的なキャッシュをSDKに提供します。使用するには、工場関数を使用してインスタンスを作成し、インスタンスをFirestoreSettings.cacheに設定し、設定オブジェクトを使用してinitializeFirestoreを呼び出します。
PersistentMultipletabmanager複数のタブをサポートするタブマネージャー。 SDKは、SDKを使用してすべてのタブで行われたクエリと変異を同期します。
stastentsingletabmanager 1つのタブのみをサポートするタブマネージャー、タブ間で同期は実行されません。
stastentingletabmanagersettings PersistentSingleTabManagerインスタンスを構成するために入力します。
snapshotlistenoptions onsnapshot()およびquerysnapshot.docchanges()に渡すことができるオプションオブジェクト。結果セットに含める変更のタイプを制御します。
SnapShoToptions DocumentSnapshotからデータの取得方法を構成するオプション(たとえば、最終的な値にまだ設定されていないサーバータイムスタンプの望ましい動作)。
TransactionOptionsトランザクション動作をカスタマイズするオプション。
購読を解除する呼び出されたときにリスナーを削除するonSnapshot()によって返される関数。

変数

変数説明
cache_size_unlimited LRUガベージコレクションを示すために使用される定数は無効にする必要があります。この値を設定のcacheSizeBytesとして設定し、 Firestoreインスタンスに渡されます。

タイプエイリアス

タイプエイリアス説明
AddPrefixTokeysすべてのキーにドットに追加された外側キーが付いている新しいマップを返します。
AggregateFieldType FirestoreによってサポートされているすべてのAggregateFieldタイプの連合。
aggregatespecdataキーがAggregateSpecから取得され、その値は、入力AggregateSpecから対応するAggregateFieldによって実行される集約の結果であるタイプ。
AggregateType実行される骨材タイプを表すユニオンタイプ。
ChildUpdateFields特定のタイプT1のネストされたフィールドを計算するためのヘルパー。これは、 undefined | {...} (オプションの小道具で発生)または{a: A} | {b: B}このユースケースでは、 T[K]は式として評価され、分布していないため、 V Record上の組合タイプのT[K]を分配するために使用されます。 https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-typesを参照してください
DocumentChangeType DocumentChangeのタイプは、「追加」、「削除」、または「変更」される場合があります。
firestoreerrorcode Firestoreステータスコードのセット。コードは、grpcによって公開されているコードで同じです:https://github.com/grpc/grpc/blob/master/doc/statuscodes.md可能な値: - 「キャンセル」:操作はキャンセルされました(通常は発信者によって)。 - 「不明」:異なるエラードメインからの不明なエラーまたはエラー。 - 'invalid-argument':クライアントは無効な引数を指定しました。これは「失敗した前提条件」とは異なることに注意してください。 「Invalid-Argument」は、システムの状態に関係なく問題がある引数を示します(たとえば、無効なフィールド名)。 - 「締め切り」:操作が完了する前に期限が切れた締め切り。システムの状態を変更する操作の場合、操作が正常に完了した場合でも、このエラーが返される場合があります。たとえば、サーバーからの応答の成功は、期限が切れるのに十分長く遅れていた可能性があります。 - 'not-found':要求されたドキュメントは見つかりませんでした。 - 「すでに存在する」:作成を試みた文書が既に存在します。 - 「許可-Denied」:発信者は、指定された操作を実行する許可を持っていません。 - 「Resource-Execresd」:一部のリソースは使い果たされており、おそらくユーザーごとのクォータ、またはファイルシステム全体がスペースが外れています。 - 「失敗前処理」:システムが操作の実行に必要な状態にないため、操作は拒否されました。 - 「中止」:通常、トランザクションが中止するなどの並行性の問題が原因で、操作は中止されました。 - 「実装されていない」:操作は実装されていないか、サポート/有効化されていません。 - 「内部」:内部エラー。基礎となるシステムによって予想されるいくつかの侵略が壊れていることを意味します。これらのエラーのいずれかが表示されている場合、何かが非常に壊れています。 - 「利用できない」:サービスは現在利用できません。これはおそらく一時的な状態であり、バックオフで再試行することで修正される場合があります。 - 「データロス」:回復不可能なデータ損失または腐敗。 - 「認証されていない」:リクエストには、操作の有効な認証資格情報がありません。
firestoreLocalcacheサポートされているすべてのSDKキャッシュレイヤーからのユニオンタイプ。
listensourceクエリが耳を傾けるソースを説明してください。 defaultに設定して、キャッシュとサーバーの変更の両方をリッスンします。キャッシュのみをcacheように設定して、キャッシュの変更のみを聞きます。
MemoryGarBageCollectorメモリローカルキャッシュのためのすべてのサポートガベージコレクターからのユニオンタイプ。
NestedUpDateFields各フィールド(例: 'bar')について、すべてのネストされたキーを見つけます(例:{ 'bar.baz':t1、 'bar.qux':t2 } )。それらと交差して、すべてオプションとしてマークされたすべての可能なキーを含む単一のマップを作成します
OrderByDirection Orderby()句の方向は、「DESC」または「ASC」(下降または上昇)として指定されています。
PartialWithFieldValue TypeScriptのPartial<T>と同様ですが、ネストされたフィールドを省略し、フィールド値をプロパティ値として渡すことができます。
PersistentTabManager利用可能なすべてのタブマネージャーの組合。
原生的プリミティブタイプ。
QueryConstraintTypeこのSDKで利用可能なさまざまなクエリの制約について説明します。
QueryFilterConstraint QueryFilterConstraintqueryfieldfilterconstraintquerycompositefilterconstraintを表すヘルパーユニオンタイプです
querynonfilterconstraint QueryNonFilterConstraint 、ドキュメントのセットを絞り込んだり注文したりするために使用されるQueryConstraintsを表すヘルパーユニオンタイプですが、ドキュメントフィールドで明示的にフィルタリングしません。 QueryNonFilterConstraint sは、 orderby()を呼び出すことによって作成されますstartat()startafter()endbefore()endat()limit()またはlimittolast()をquery()に渡すことができ、 QueryConstraintも含まれる新しいqueryインスタンスを作成できます。
setoptions setdoc()の動作を構成するオプションオブジェクト、および電話。これらの呼び出しは、ターゲットドキュメント全体を上書きするのではなく、 SetOptionsマージを実行するように構成できますmerge: true
タスクステートバンドルロードタスクの状態を表します。 「エラー」と「成功」の両方が状態を沈めています。タスクは中止または完了し、報告された後に更新はありません。
ユニオンインターセクションユニオンタイプU = T1 | T2 | ...が与えられますU = T1 | T2 | ... 、交差したタイプ(T1 & T2 & ...)を返します。分配条件付きタイプと条件付きタイプからの推論を使用します。これは、対照的位置の同じタイプ変数の複数の候補が交差タイプを推測するためです。 https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-in​​ference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-typeto-intersection -タイプ
updatedataデータを更新する( updatedoc()で使用するため)値にマッピングされたフィールドパス(「foo」または「foo.baz」など)で構成されています。ドットを含むフィールドは、ドキュメント内のネストされたフィールドを参照します。 FieldValuesは、プロパティ値として渡すことができます。
wherefilterop where()句のフィルター条件は、文字列 '&lt;'、 '&lt; ='、 '=='、 '!='、 '&gt; ='、 '&gt;'、 'array-contains'を使用して指定されています。 、 'in'、 'array-contains-any'、および 'not-in'。
withfieldvalueタイプの安全性を維持しながら、フィールド値をプロパティ値として渡すことができます。

関数(アプリ、...)

getFirestore(アプリ)

提供されたFireBaseAppに関連付けられている既存のデフォルトのFirestoreインスタンスを返します。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。

サイン:

export declare function getFirestore(app: FirebaseApp): Firestore;

パラメーター

パラメータータイプ説明
アプリFireBaseapp返されたファイヤーストアインスタンスが関連付けられているFireBaseappインスタンス。

戻り値:

ファイヤーストア

提供されたアプリのデフォルトのファイヤーストアインスタンス。

getFirestore(APP、DatabaseID)

このAPIは、開発者のプレビューとして提供されており、受け取ったフィードバックに基づいて変更される場合があります。このAPIを生産環境で使用しないでください。

提供されたFireBaseappに関連付けられている既存の名前付きファイヤーストアインスタンスを返します。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。

サイン:

export declare function getFirestore(app: FirebaseApp, databaseId: string): Firestore;

パラメーター

パラメータータイプ説明
アプリFireBaseapp返されたファイヤーストアインスタンスが関連付けられているFireBaseappインスタンス。
DatabaseIDデータベースの名前。

戻り値:

ファイヤーストア

提供されたアプリの名前付きファイヤーストアインスタンス。

initializeFirestore(APP、設定、データベースID)

提供された設定でファイアストアの新しいインスタンスを初期化します。 getFirestore()を含む他の関数の前にのみ呼び出すことができます。カスタム設定が空の場合、この関数はgetFirestore()を呼び出すのと同等です

サイン:

export declare function initializeFirestore(app: FirebaseApp, settings: FirestoreSettings, databaseId?: string): Firestore;

パラメーター

パラメータータイプ説明
アプリFireBaseapp Firestoreインスタンスが関連付けられるFireBaseapp
設定Firestoresettings Firestoreインスタンスを構成する設定オブジェクト。
DatabaseIDデータベースの名前。

戻り値:

ファイヤーストア

新しく初期化されたファイヤーストアインスタンス。

関数(ファイヤーストア、...)

ClearIndexedDBPerSistence(Firestore)

永続的なストレージをクリアします。これには、保留中の書き込みとキャッシュドキュメントが含まれます。

Firestoreインスタンスが開始されないときに呼び出す必要があります(アプリが終了した後、またはアプリが最初に初期化されたとき)。起動時には、この関数は他の機能の前に呼び出されなければなりません( intializeFirestore()またはgetFirestore()以外))。 Firestoreインスタンスがまだ実行されている場合、 failed-preconditionのエラーコードで約束が拒否されます

サイン:

export declare function clearIndexedDbPersistence(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアファイアストアインスタンスは、永続性をクリアします。

戻り値:

約束<void>

永続的なストレージがクリアされたときに解決されるPromise 。それ以外の場合、約束はエラーで拒否されます。

コレクション(ファイヤーストア、パス、パスセグメント)

指定された絶対パスでのコレクションを参照するCollectionReferenceインスタンスを取得します。

サイン:

export declare function collection(firestore: Firestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアルートFirestoreインスタンスへの参照。
パスコレクションへのスラッシュ分離されたパス。
Pathsegments弦[]最初の引数に関連する追加のパスセグメント。

戻り値:

CollectionReference < documentDatadocumentdata >

CollectionReferenceインスタンス。

例外

最終パスに偶数のセグメントがあり、コレクションを指していない場合。

CollectionGroup(Firestore、CollectionID)

指定されたcollectionIdでコレクションまたはサブコレクションに含まれるデータベース内のすべてのドキュメントを含む新しいQueryインスタンスを作成および返信します

サイン:

export declare function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアルートFirestoreインスタンスへの参照。
CollectionIdクエリするコレクションを識別します。パスの最後のセグメントとしてこのIDを使用したすべてのコレクションまたはサブコレクションが含まれます。スラッシュを含めることはできません。

戻り値:

クエリ< documentDatadocumentdata >

作成されたQuery

ConnectFirestoreEmulator(ファイヤーストア、ホスト、ポート、オプション)

このインスタンスを変更して、Cloud Firestoreエミュレーターと通信します。

サイン:

export declare function connectFirestoreEmulator(firestore: Firestore, host: string, port: number, options?: {
    mockUserToken?: EmulatorMockTokenOptions | string;
}): void;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアエミュレータに接続するように構成するFirestoreインスタンス。
ホストエミュレータホスト(例:localhost)。
ポート番号エミュレータポート(例:9000)。
オプション{mockusertoken?: emulatormocktokenoptions |弦; }

戻り値:

空所

DisableNetwork(Firestore)

このインスタンスのネットワーク使用を無効にします。 enableNetwork()を介して再度有効にすることができます。ネットワークが無効になっている間、スナップショットリスナー、 getDoc() 、またはgetDocs()呼び出しはキャッシュから結果を返し、ネットワークが復元されるまで任意の書き込み操作がキューになります。

サイン:

export declare function disableNetwork(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

約束<void>

ネットワークが無効になった後に解決されるPromise

doc(ファイヤーストア、パス、パスセグメント)

指定された絶対パスでドキュメントを参照するDocumentReferenceインスタンスを取得します。

サイン:

export declare function doc(firestore: Firestore, path: string, ...pathSegments: string[]): DocumentReference<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアルートFirestoreインスタンスへの参照。
パスドキュメントへのスラッシュ分離パス。
Pathsegments弦[]最初の引数に対して適用される追加のパスセグメント。

戻り値:

文書化< documentDatadocumentdata >

DocumentReferenceインスタンス。

例外

最終パスに奇数のセグメントがあり、ドキュメントを指していない場合。

enabableIndexedDBPerSistence(Firestore、Persistencesettings)

この機能は、将来の主要なリリースで削除されます。代わりに、 FirestoreSettings.localCachePersistentLocalCacheのインスタンスに設定して、indexedDBキャッシュをオンにします。 FirestoreSettings.localCacheが既に指定されている場合、この関数を呼び出すと、例外がスローされます。

可能であれば、永続的なストレージを有効にしようとします。

障害時に、 enableIndexedDbPersistence()約束を拒否するか、例外をスローします。これが失敗する理由はいくつかありますが、これはエラーに関するcodeによって識別できます。

*順調に失敗する:アプリは別のブラウザタブですでに開いています。 *実装なし:ブラウザは、オフラインの永続性実装と互換性がありません。

障害後でも、ファイアストアインスタンスは使用可能なままであるが、オフラインの持続性が無効になることに注意してください。

node.js環境では永続性を使用することはできません。

サイン:

export declare function enableIndexedDbPersistence(firestore: Firestore, persistenceSettings?: PersistenceSettings): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアFirestoreインスタンスは、持続性を有効にします。
PersistencesEttings PersistencesEttingsオプションの設定オブジェクトは、永続性を構成します。

戻り値:

約束<void>

永続的なストレージを有効にすることを成功裏に表すPromise

enablemultiTabindexeddbpersistence(Firestore)

この機能は、将来の主要なリリースで削除されます。代わりに、 FirestoreSettings.localCache PersistentLocalCacheのインスタンスに設定して、indexedDBキャッシュをオンにします。 FirestoreSettings.localCacheが既に指定されている場合、この関数を呼び出すと、例外がスローされます。

可能であれば、マルチタブの永続的なストレージを有効にしようとします。すべてのタブで有効になっている場合、すべての接続されたインスタンスでクエリの共有実行やレイテンシ補償のローカルドキュメントアップデートなど、すべての操作がローカルの永続性へのアクセスを共有します。

障害時に、 enableMultiTabIndexedDbPersistence()約束を拒否するか、例外をスローします。これが失敗する理由はいくつかありますが、これはエラーに関するcodeによって識別できます。

*前提条件の失敗:アプリは既に別のブラウザタブで開いており、Multi-Tabは有効になっていません。 *実装なし:ブラウザは、オフラインの永続性実装と互換性がありません。

障害後でも、ファイアストアインスタンスは使用可能なままであるが、オフラインの持続性が無効になることに注意してください。

サイン:

export declare function enableMultiTabIndexedDbPersistence(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアFirestoreインスタンスは、持続性を有効にします。

戻り値:

約束<void>

永続的なストレージを有効にすることを成功裏に表すPromise

enablenetwork(ファイヤーストア)

DisableNetwork()を事前に呼び出した後、このFirestoreインスタンスにネットワークを使用できること

サイン:

export declare function enableNetwork(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

約束<void>

ネットワークが有効になったら解決されるPromise

getPersistEntCacheIndexManager(Firestore)

特定のFirestoreオブジェクトで使用されるPersistentCacheインデックスマネージャーを返します。

PersistentCacheIndexManagerインスタンス、またはローカルの永続的なストレージが使用されていない場合はnull

サイン:

export declare function getPersistentCacheIndexManager(firestore: Firestore): PersistentCacheIndexManager | null;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

PersistentCacheIndexManager |ヌル

LoadBundle(Firestore、Bunddeata)

地元のキャッシュにファイヤーストアバンドルをロードします。

サイン:

export declare function loadBundle(firestore: Firestore, bundleData: ReadableStream<Uint8Array> | ArrayBuffer | string): LoadBundleTask;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアバンドルをロードするファイヤーストアインスタンス。
ReadAbleStream <UINT8ARRAY> | arraybuffer |弦ロードするバンドルを表すオブジェクト。有効なオブジェクトは、 ArrayBufferReadableStream<Uint8Array> 、またはstringです。

戻り値:

loadbundletask

LoadBundleTaskオブジェクト。これは、進行状況の更新、および完了またはエラーイベントを発信者に通知します。それはPromise<LoadBundleTaskProgress>

名前を付けた(ファイヤーストア、名前)

指定された名前で識別されたローカルキャッシュからのファイヤーストアクエリを読み取ります。

名前付きクエリは(結果のドキュメントとともに)サーバー側のバンドルにパッケージ化され、 loadBundleを使用してローカルキャッシュにロードされます。ローカルキャッシュにしたら、この方法を使用して、名前でクエリを抽出します。

サイン:

export declare function namedQuery(firestore: Firestore, name: string): Promise<Query | null>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアFirestoreインスタンスからのクエリを読む。
名前クエリの名前。

戻り値:

約束<クエリ| null>

クエリまたはnullで解決されるPromise

Ansnapshotsinsync(Firestore、Observer)

スナップショットインシンクイベントのリスナーを添付します。スナップショットインシンクイベントは、単一のサーバーで生成された変更が複数のリスナーに影響を与える場合でも、特定の変更の影響を受けたすべてのリスナーが発生したことを示しています。

注:スナップショットインシンクイベントは、リスナーが互いに同期していることを示していますが、それらのスナップショットがサーバーと同期しているかどうかに関係していません。個々のリスナーでSnapShotMetadataを使用して、スナップショットがキャッシュからのものかサーバーからであるかを判断します。

サイン:

export declare function onSnapshotsInSync(firestore: Firestore, observer: {
    next?: (value: void) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアスナップショットを同期するためのファイアストアのインスタンス。
観察者{next?:( value:void)=> void;エラー?:(エラー: FirestoreError )=> void;完了:()=> void; } nexterrorコールバックを含む単一のオブジェクト。

戻り値:

購読を解除する

スナップショットリスナーをキャンセルするために呼び出される可能性のある登録解除関数。

onsnapshotsinsync(firestore、onsync)

スナップショットインシンクイベントのリスナーを添付します。スナップショットインシンクイベントは、単一のサーバーで生成された変更が複数のリスナーに影響を与える場合でも、特定の変更の影響を受けたすべてのリスナーが発生したことを示しています。

注:スナップショットインシンクイベントは、リスナーが互いに同期していることを示していますが、それらのスナップショットがサーバーと同期しているかどうかに関係していません。個々のリスナーでSnapshotMetadataを使用して、スナップショットがキャッシュからのものかサーバーからであるかを判断します。

サイン:

export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアスナップショットを同期するためのFirestoreインスタンス。
onsync ()=> voidすべてのスナップショットリスナーが互いに同期しているたびに呼び出されるコールバック。

戻り値:

購読を解除する

スナップショットリスナーをキャンセルするために呼び出される可能性のある登録解除関数。

RunTransaction(Firestore、UpdateFunction、Options)

指定されたupdateFunctionを実行し、トランザクション内で適用される変更をコミットしようとします。トランザクション内で読み取られたドキュメントが変更された場合、Cloud FirestoreはupdateFunctionを取得します。 5回の試行後にコミットに失敗した場合、トランザクションは失敗します。

単一のトランザクションで許可されている最大数は500です。

サイン:

export declare function runTransaction<T>(firestore: Firestore, updateFunction: (transaction: Transaction) => Promise<T>, options?: TransactionOptions): Promise<T>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアこのトランザクションを実行するためのFirestoreデータベースへの参照。
UpdateFunction (トランザクション:トランザクション)=>約束<T>トランザクションコンテキスト内で実行する機能。
オプションTransactionOptionsコミットする試みの最大数を構成するオプションオブジェクト。

戻り値:

約束<t>

トランザクションが正常に完了したか、明示的に中止された場合( updateFunction失敗した約束を返しました)、 updateFunctionによって返された約束ここに返されます。それ以外の場合、トランザクションが失敗した場合、対応する障害エラーによる拒否された約束が返されます。

setIndexConfiguration(Firestore、構成)

このAPIは、開発者のプレビューとして提供されており、受け取ったフィードバックに基づいて変更される場合があります。このAPIを生産環境で使用しないでください。

キャッシュインデックスを手動で作成する代わりに、 enablePersistentCacheIndexAutoCreation()を使用することを検討して、SDKがローカルで実行されるクエリのキャッシュインデックスを作成するかどうかを決定させます。

ローカルクエリ実行のインデックス作成を構成します。以前のインデックス構成はオーバーライドされます。インデックス構成が続くと、 Promise解決します。

インデックスエントリ自体は非同期に作成されます。インデックスがまだ利用できない場合でも、インデックスが必要なクエリを引き続き使用できます。クエリ実行は、インデックスエントリが書き込まれると、インデックスの使用を自動的に開始します。

インデックスは、IndexEdDBの持続性でのみサポートされます。 indexedDBが有効になっていない場合、index構成は無視されます。

サイン:

export declare function setIndexConfiguration(firestore: Firestore, configuration: IndexConfiguration): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアFIRESTOREインスタンスのインデックスを構成します。
構成IndexConfigurationインデックス定義。

戻り値:

約束<void>

すべてのインデックスが正常に構成された後に解決するPromise

例外

JSON形式が無効である場合、FireStoreError。

SetindexConfiguration(Firestore、JSON)

このAPIは、開発者のプレビューとして提供されており、受け取ったフィードバックに基づいて変更される場合があります。このAPIを生産環境で使用しないでください。

キャッシュインデックスを手動で作成する代わりに、 enablePersistentCacheIndexAutoCreation()を使用することを検討して、SDKがローカルで実行されるクエリのキャッシュインデックスを作成するかどうかを決定させます。

ローカルクエリ実行のインデックス作成を構成します。以前のインデックス構成はオーバーライドされます。インデックス構成が続くと、 Promise解決します。

インデックスエントリ自体は非同期に作成されます。インデックスがまだ利用できない場合でも、インデックスが必要なクエリを引き続き使用できます。クエリ実行は、インデックスエントリが書き込まれると、インデックスの使用を自動的に開始します。

インデックスは、IndexEdDBの持続性でのみサポートされます。インデックス構成を設定する前に、 enableIndexedDbPersistence()またはenableMultiTabIndexedDbPersistence()いずれかを呼び出します。 indexedDBが有効になっていない場合、index構成は無視されます。

このメソッドは、FirebaseCLIによってエクスポートされるJSON形式を受け入れます( firebase firestore:indexes )。 JSON形式が無効である場合、このメソッドはエラーをスローします。

サイン:

export declare function setIndexConfiguration(firestore: Firestore, json: string): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストアFIRESTOREインスタンスのインデックスを構成します。
jsonFirebase CLIによってエクスポートされるJSON形式。

戻り値:

約束<void>

すべてのインデックスが正常に構成された後に解決するPromise

例外

JSON形式が無効である場合、FireStoreError。

終了(ファイヤーストア)

提供されたファイアストアインスタンスを終了します。

clearIndexedDbPersistence() terminate()のみを呼び出した後も使用できます。他の機能はFirestoreErrorを投げます

終了後に再起動するには、 getFirestore()でFireBaseFirestoreの新しいインスタンスを作成します

終了は保留中の書き込みをキャンセルせず、サーバーからの応答を待っている約束は解決されません。永続性が有効になっている場合、次にこのインスタンスを開始するときに、これらの書き込みをサーバーに送信することを再開します。

サイン:

export declare function terminate(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

約束<void>

インスタンスが正常に終了したときに解決されるPromise

waitforpendingwrites(ファイヤーストア)

アクティブなユーザーに対する現在保留中のすべての書き込みがバックエンドによって認められるまで待ちます。

未解決の執筆がない場合、返された約束はすぐに解決します。それ以外の場合、約束は、以前に発行されたすべての書き込み(以前のアプリセッションで書かれたものを含む)を待っていますが、関数が呼び出された後に追加された書き込みを待ちません。追加の書き込みを待ちたい場合は、再度waitForPendingWrites()に電話してください。

未解決のwaitForPendingWrites()約束は、ユーザーの変更中に拒否されます。

サイン:

export declare function waitForPendingWrites(firestore: Firestore): Promise<void>;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

約束<void>

現在保留中のすべての書き込みがバックエンドによって認められたときに解決するPromise

WriteBatch(Firestore)

単一の原子操作として複数の書き込みを実行するために使用される書き込みバッチを作成します。単一の書き込みバッチで許可されている最大数の書き込みは500です。

トランザクションとは異なり、書き込みデータに書き込みデータを条件付けする必要がない場合に、書き込みバッチがオフラインで持続するため、好ましいです。

サイン:

export declare function writeBatch(firestore: Firestore): WriteBatch;

パラメーター

パラメータータイプ説明
消防署ファイヤーストア

戻り値:

書き込みバッチ

複数の書き込みをアトミックに実行するために使用できる書き込みバッチ

関数()

カウント()

クエリの結果セットでドキュメントのカウントを計算するために使用できる集約フィールドオブジェクトを作成します。

サイン:

export declare function count(): AggregateField<number>;

戻り値:

アグリゲートフィールド<number>

deletefield()

削除のフィールドをマークするために、 {merge: true}を使用してupdatedoc()またはsetdoc()で使用するためにセンチネルを返します。

サイン:

export declare function deleteField(): FieldValue;

戻り値:

FieldValue

documentid()

ドキュメントのIDを参照するために、特別なSentinel FieldPathを返します。ドキュメントIDでソートまたはフィルタリングするためにクエリで使用できます。

サイン:

export declare function documentId(): FieldPath;

戻り値:

FieldPath

getFirestore()

デフォルトのFireBaseappに関連付けられている既存のデフォルトのFirestoreインスタンスを返します。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。

サイン:

export declare function getFirestore(): Firestore;

戻り値:

ファイヤーストア

デフォルトアプリのデフォルトのファイヤーストアインスタンス。

MemoryeAgergarBageCollector()

MemoryEagerGarbageCollectorのインスタンスを作成します。これは、特に明示的に指定されていない限り、デフォルトのガベージコレクターでもあります。

サイン:

export declare function memoryEagerGarbageCollector(): MemoryEagerGarbageCollector;

戻り値:

MemoryeAgergarBageCollector

PersistentMultipletabmanager()

PersistentMultipleTabManagerのインスタンスを作成します

サイン:

export declare function persistentMultipleTabManager(): PersistentMultipleTabManager;

戻り値:

PersistentMultipletabmanager

servertimestamp()

setdoc()またはupdatedoc()で使用されたセンチネルを返して、書かれたデータにサーバーで生成されたタイムスタンプを含めます。

サイン:

export declare function serverTimestamp(): FieldValue;

戻り値:

FieldValue

function(databaseid、...)

getFirestore(databaseid)

このAPIは、開発者のプレビューとして提供されており、受け取ったフィードバックに基づいて変更される場合があります。このAPIを生産環境で使用しないでください。

デフォルトのFireBaseappに関連付けられている既存の名前付きFirestoreインスタンスを返します。インスタンスが存在しない場合は、デフォルト設定で新しいインスタンスを初期化します。

サイン:

export declare function getFirestore(databaseId: string): Firestore;

パラメーター

パラメータータイプ説明
DatabaseIDデータベースの名前。

戻り値:

ファイヤーストア

デフォルトアプリの名前付きFirestoreインスタンス。

関数(要素、...)

arrayremove(要素)

SetDoc()で使用できる特別な値を返したり、サーバーに既に存在する配列値から指定された要素を削除するようにサーバーに指示します。 All instances of each element specified will be removed from the array. If the field being modified is not already an array it will be overwritten with an empty array.

サイン:

export declare function arrayRemove(...elements: unknown[]): FieldValue;

パラメーター

パラメータータイプ説明
要素未知[] The elements to remove from the array.

戻り値:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc()

arrayUnion(elements)

Returns a special value that can be used with setDoc() or updateDoc() that tells the server to union the given elements with any array value that already exists on the server. Each specified element that doesn't already exist in the array will be added to the end. If the field being modified is not already an array it will be overwritten with an array containing exactly the specified elements.

サイン:

export declare function arrayUnion(...elements: unknown[]): FieldValue;

パラメーター

パラメータータイプ説明
要素未知[] The elements to union into the array.

戻り値:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc()

function(field, ...)

average(field)

Create an AggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

サイン:

export declare function average(field: string | FieldPath): AggregateField<number | null>;

パラメーター

パラメータータイプ説明
分野string | FieldPath Specifies the field to average across the result set.

戻り値:

AggregateField <number | null>

sum(field)

Create an AggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

サイン:

export declare function sum(field: string | FieldPath): AggregateField<number>;

パラメーター

パラメータータイプ説明
分野string | FieldPath Specifies the field to sum across the result set.

戻り値:

AggregateField <number>

function(fieldPath, ...)

orderBy(fieldPath, directionStr)

Creates a QueryOrderByConstraint that sorts the query result by the specified field, optionally in descending order instead of ascending.

サイン:

export declare function orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): QueryOrderByConstraint;

パラメーター

パラメータータイプ説明
fieldPath string | FieldPath The field to sort by.
directionStr OrderByDirection Optional direction to sort by ('asc' or 'desc'). If not specified, order will be ascending.

戻り値:

QueryOrderByConstraint

The created QueryOrderByConstraint

where(fieldPath, opStr, value)

Creates a QueryFieldFilterConstraint that enforces that documents must contain the specified field and that the value should satisfy the relation constraint provided.

サイン:

export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): QueryFieldFilterConstraint;

パラメーター

パラメータータイプ説明
fieldPath string | FieldPath The path to compare
opStr WhereFilterOp The operation string (eg "&lt;", "&lt;=", "==", "&lt;", "&lt;=", "!=").
価値未知The value for comparison

戻り値:

QueryFieldFilterConstraint

The created QueryFieldFilterConstraint

function(fieldValues, ...)

endAt(fieldValues)

Creates a QueryEndAtConstraint that modifies the result set to end at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

サイン:

export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint;

パラメーター

パラメータータイプ説明
fieldValues未知[] The field values to end this query at, in order of the query's order by.

戻り値:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

endBefore(fieldValues)

Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

サイン:

export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint;

パラメーター

パラメータータイプ説明
fieldValues未知[] The field values to end this query before, in order of the query's order by.

戻り値:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

startAfter(fieldValues)

Creates a QueryStartAtConstraint that modifies the result set to start after the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

サイン:

export declare function startAfter(...fieldValues: unknown[]): QueryStartAtConstraint;

パラメーター

パラメータータイプ説明
fieldValues未知[] The field values to start this query after, in order of the query's order by.

戻り値:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

startAt(fieldValues)

Creates a QueryStartAtConstraint that modifies the result set to start at the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.

サイン:

export declare function startAt(...fieldValues: unknown[]): QueryStartAtConstraint;

パラメーター

パラメータータイプ説明
fieldValues未知[] The field values to start this query at, in order of the query's order by.

戻り値:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

function(indexManager, ...)

deleteAllPersistentCacheIndexes(indexManager)

Removes all persistent cache indexes.

Please note this function will also deletes indexes generated by setIndexConfiguration() , which is deprecated.

サイン:

export declare function deleteAllPersistentCacheIndexes(indexManager: PersistentCacheIndexManager): void;

パラメーター

パラメータータイプ説明
indexManager PersistentCacheIndexManager

戻り値:

空所

disablePersistentCacheIndexAutoCreation(indexManager)

Stops creating persistent cache indexes automatically for local query execution. The indexes which have been created by calling enablePersistentCacheIndexAutoCreation() still take effect.

サイン:

export declare function disablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void;

パラメーター

パラメータータイプ説明
indexManager PersistentCacheIndexManager

戻り値:

空所

enablePersistentCacheIndexAutoCreation(indexManager)

Enables the SDK to create persistent cache indexes automatically for local query execution when the SDK believes cache indexes can help improve performance.

This feature is disabled by default.

サイン:

export declare function enablePersistentCacheIndexAutoCreation(indexManager: PersistentCacheIndexManager): void;

パラメーター

パラメータータイプ説明
indexManager PersistentCacheIndexManager

戻り値:

空所

function(left, ...)

aggregateFieldEqual(left, right)

Compares two 'AggregateField ` instances for equality.

サイン:

export declare function aggregateFieldEqual(left: AggregateField<unknown>, right: AggregateField<unknown>): boolean;

パラメーター

パラメータータイプ説明
AggregateField <unknown> Compare this AggregateField to the right .
AggregateField <unknown> Compare this AggregateField to the left .

戻り値:

ブール値

aggregateQuerySnapshotEqual(left, right)

Compares two AggregateQuerySnapshot instances for equality.

Two AggregateQuerySnapshot instances are considered "equal" if they have underlying queries that compare equal, and the same data.

サイン:

export declare function aggregateQuerySnapshotEqual<AggregateSpecType extends AggregateSpec, AppModelType, DbModelType extends DocumentData>(left: AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>, right: AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>): boolean;

パラメーター

パラメータータイプ説明
AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType> The first AggregateQuerySnapshot to compare.
AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType> The second AggregateQuerySnapshot to compare.

戻り値:

ブール値

true if the objects are "equal", as defined above, or false otherwise.

queryEqual(left, right)

Returns true if the provided queries point to the same collection and apply the same constraints.

サイン:

export declare function queryEqual<AppModelType, DbModelType extends DocumentData>(left: Query<AppModelType, DbModelType>, right: Query<AppModelType, DbModelType>): boolean;

パラメーター

パラメータータイプ説明
クエリ<AppModelType, DbModelType> A Query to compare.
クエリ<AppModelType, DbModelType> A Query to compare.

戻り値:

ブール値

true if the references point to the same location in the same Firestore database.

refEqual(left, right)

Returns true if the provided references are equal.

サイン:

export declare function refEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>, right: DocumentReference<AppModelType, DbModelType> | CollectionReference<AppModelType, DbModelType>): boolean;

パラメーター

パラメータータイプ説明
DocumentReference <AppModelType, DbModelType> | CollectionReference <AppModelType, DbModelType> A reference to compare.
DocumentReference <AppModelType, DbModelType> | CollectionReference <AppModelType, DbModelType> A reference to compare.

戻り値:

ブール値

true if the references point to the same location in the same Firestore database.

snapshotEqual(left, right)

Returns true if the provided snapshots are equal.

サイン:

export declare function snapshotEqual<AppModelType, DbModelType extends DocumentData>(left: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>, right: DocumentSnapshot<AppModelType, DbModelType> | QuerySnapshot<AppModelType, DbModelType>): boolean;

パラメーター

パラメータータイプ説明
DocumentSnapshot <AppModelType, DbModelType> | QuerySnapshot <AppModelType, DbModelType> A snapshot to compare.
DocumentSnapshot <AppModelType, DbModelType> | QuerySnapshot <AppModelType, DbModelType> A snapshot to compare.

戻り値:

ブール値

true if the snapshots are equal.

function(limit, ...)

limit(limit)

Creates a QueryLimitConstraint that only returns the first matching documents.

サイン:

export declare function limit(limit: number): QueryLimitConstraint;

パラメーター

パラメータータイプ説明
限界番号The maximum number of items to return.

戻り値:

QueryLimitConstraint

The created QueryLimitConstraint

limitToLast(limit)

Creates a QueryLimitConstraint that only returns the last matching documents.

You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution.

サイン:

export declare function limitToLast(limit: number): QueryLimitConstraint;

パラメーター

パラメータータイプ説明
限界番号The maximum number of items to return.

戻り値:

QueryLimitConstraint

The created QueryLimitConstraint

function(logLevel, ...)

setLogLevel(logLevel)

Sets the verbosity of Cloud Firestore logs (debug, error, or silent).

サイン:

export declare function setLogLevel(logLevel: LogLevel): void;

パラメーター

パラメータータイプ説明
logLevel LogLevel The verbosity you set for activity and error logging. Can be any of the following values:
  • debug for the most verbose logging level, primarily for debugging.
  • error to log errors only.
  • silent to turn off logging.

戻り値:

空所

function(n, ...)

increment(n)

Returns a special value that can be used with setDoc() or updateDoc() that tells the server to increment the field's current value by the given value.

If either the operand or the current field value uses floating point precision, all arithmetic follows IEEE 754 semantics. If both values are integers, values outside of JavaScript's safe number range ( Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER ) are also subject to precision loss. Furthermore, once processed by the Firestore backend, all integer operations are capped between -2^63 and 2^63-1.

If the current field value is not of type number , or if the field does not yet exist, the transformation sets the field to the given value.

サイン:

export declare function increment(n: number): FieldValue;

パラメーター

パラメータータイプ説明
n番号The value to increment by.

戻り値:

FieldValue

The FieldValue sentinel for use in a call to setDoc() or updateDoc()

function(query, ...)

getAggregateFromServer(query, aggregateSpec)

Calculates the specified aggregations over the documents in the result set of the given query without actually downloading the documents.

Using this function to perform aggregations is efficient because only the final aggregation values, not the documents' data, are downloaded. This function can perform aggregations of the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).

The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server.

サイン:

export declare function getAggregateFromServer<AggregateSpecType extends AggregateSpec, AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, aggregateSpec: AggregateSpecType): Promise<AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query whose result set is aggregated over.
aggregateSpec AggregateSpecType An AggregateSpec object that specifies the aggregates to perform over the result set. The AggregateSpec specifies aliases for each aggregate, which can be used to retrieve the aggregate result.

戻り値:

Promise< AggregateQuerySnapshot <AggregateSpecType, AppModelType, DbModelType>>

const aggregateSnapshot = await getAggregateFromServer(query, {
  countOfDocs: count(),
  totalHours: sum('hours'),
  averageScore: average('score')
});

const countOfDocs: number = aggregateSnapshot.data().countOfDocs;
const totalHours: number = aggregateSnapshot.data().totalHours;
const averageScore: number | null = aggregateSnapshot.data().averageScore;

getCountFromServer(query)

Calculates the number of documents in the result set of the given query without actually downloading the documents.

Using this function to count the documents is efficient because only the final count, not the documents' data, is downloaded. This function can count the documents in cases where the result set is prohibitively large to download entirely (thousands of documents).

The result received from the server is presented, unaltered, without considering any local state. That is, documents in the local cache are not taken into consideration, neither are local modifications not yet synchronized with the server. Previously-downloaded results, if any, are not used. Every invocation of this function necessarily involves a round trip to the server.

サイン:

export declare function getCountFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<AggregateQuerySnapshot<{
    count: AggregateField<number>;
}, AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query whose result set size is calculated.

戻り値:

Promise< AggregateQuerySnapshot <{ count: AggregateField <number>; }, AppModelType, DbModelType>>

A Promise that will be resolved with the count; the count can be retrieved from snapshot.data().count , where snapshot is the AggregateQuerySnapshot to which the returned Promise resolves.

getDocs(query)

Executes the query and returns the results as a QuerySnapshot

サイン:

export declare function getDocs<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType>

戻り値:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

getDocsFromCache(query)

Executes the query and returns the results as a QuerySnapshot from cache. Returns an empty result set if no documents matching the query are currently cached.

サイン:

export declare function getDocsFromCache<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType>

戻り値:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

getDocsFromServer(query)

Executes the query and returns the results as a QuerySnapshot from the server. Returns an error if the network is not available.

サイン:

export declare function getDocsFromServer<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>): Promise<QuerySnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType>

戻り値:

Promise< QuerySnapshot <AppModelType, DbModelType>>

A Promise that will be resolved with the results of the query.

onSnapshot(query, observer)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, observer: {
    next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query to listen to.
観察者{ next?: (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, options, observer)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, observer: {
    next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query to listen to.
options SnapshotListenOptions Options controlling the listen behavior.
観察者{ next?: (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, onNext, onError, onCompletion)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query to listen to.
onNext (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new QuerySnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
完了時に() => void Can be provided, but will not be called since streams are never ending.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(query, options, onNext, onError, onCompletion)

Attaches a listener for QuerySnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks. The listener can be cancelled by calling the function that is returned when onSnapshot is called.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The query to listen to.
options SnapshotListenOptions Options controlling the listen behavior.
onNext (snapshot: QuerySnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new QuerySnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
完了時に() => void Can be provided, but will not be called since streams are never ending.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

query(query, compositeFilter, queryConstraints)

Creates a new immutable instance of Query that is extended to also include additional query constraints.

サイン:

export declare function query<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[]): Query<AppModelType, DbModelType>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The Query instance to use as a base for the new constraints.
compositeFilter QueryCompositeFilterConstraint The QueryCompositeFilterConstraint to apply. Create QueryCompositeFilterConstraint using and() or or()
queryConstraints QueryNonFilterConstraint [] Additional QueryNonFilterConstraint s to apply (eg orderBy() , limit() )。

戻り値:

クエリ<AppModelType, DbModelType>

例外

if any of the provided query constraints cannot be combined with the existing or new constraints.

query(query, queryConstraints)

Creates a new immutable instance of Query that is extended to also include additional query constraints.

サイン:

export declare function query<AppModelType, DbModelType extends DocumentData>(query: Query<AppModelType, DbModelType>, ...queryConstraints: QueryConstraint[]): Query<AppModelType, DbModelType>;

パラメーター

パラメータータイプ説明
クエリクエリ<AppModelType, DbModelType> The Query instance to use as a base for the new constraints.
queryConstraints QueryConstraint [] The list of QueryConstraint s to apply.

戻り値:

クエリ<AppModelType, DbModelType>

例外

if any of the provided query constraints cannot be combined with the existing or new constraints.

function(queryConstraints, ...)

and(queryConstraints)

Creates a new QueryCompositeFilterConstraint that is a conjunction of the given filter constraints. A conjunction filter includes a document if it satisfies all of the given filters.

サイン:

export declare function and(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;

パラメーター

パラメータータイプ説明
queryConstraints QueryFilterConstraint [] Optional. The list of QueryFilterConstraint s to perform a conjunction for. These must be created with calls to where()または() 、 または()

戻り値:

QueryCompositeFilterConstraint

The newly created QueryCompositeFilterConstraint

or(queryConstraints)

Creates a new QueryCompositeFilterConstraint that is a disjunction of the given filter constraints. A disjunction filter includes a document if it satisfies any of the given filters.

サイン:

export declare function or(...queryConstraints: QueryFilterConstraint[]): QueryCompositeFilterConstraint;

パラメーター

パラメータータイプ説明
queryConstraints QueryFilterConstraint [] Optional. The list of QueryFilterConstraint s to perform a disjunction for. These must be created with calls to where()または() 、 または()

戻り値:

QueryCompositeFilterConstraint

The newly created QueryCompositeFilterConstraint

function(reference, ...)

addDoc(reference, data)

Add a new document to specified CollectionReference with the given data, assigning it a document ID automatically.

サイン:

export declare function addDoc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<DocumentReference<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
参照CollectionReference <AppModelType, DbModelType> A reference to the collection to add this document to.
データWithFieldValue <AppModelType> An Object containing the data for the new document.

戻り値:

Promise< DocumentReference <AppModelType, DbModelType>>

A Promise resolved with a DocumentReference pointing to the newly created document after it has been written to the backend (Note that it won't resolve while you're offline).

collection(reference, path, pathSegments)

Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path.

サイン:

export declare function collection<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
参照CollectionReference <AppModelType, DbModelType> A reference to a collection.
パスA slash-separated path to a collection.
pathSegments弦[] Additional path segments to apply relative to the first argument.

戻り値:

CollectionReference < DocumentData , DocumentData >

The CollectionReference instance.

例外

If the final path has an even number of segments and does not point to a collection.

collection(reference, path, pathSegments)

Gets a CollectionReference instance that refers to a subcollection of reference at the the specified relative path.

サイン:

export declare function collection<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): CollectionReference<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to a Firestore document.
パスA slash-separated path to a collection.
pathSegments弦[] Additional path segments that will be applied relative to the first argument.

戻り値:

CollectionReference < DocumentData , DocumentData >

The CollectionReference instance.

例外

If the final path has an even number of segments and does not point to a collection.

deleteDoc(reference)

Deletes the document referred to by the specified DocumentReference

サイン:

export declare function deleteDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<void>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to delete.

戻り値:

Promise<void>

A Promise resolved once the document has been successfully deleted from the backend (note that it won't resolve while you're offline).

doc(reference, path, pathSegments)

Gets a DocumentReference instance that refers to a document within reference at the specified relative path. If no path is specified, an automatically-generated unique ID will be used for the returned DocumentReference

サイン:

export declare function doc<AppModelType, DbModelType extends DocumentData>(reference: CollectionReference<AppModelType, DbModelType>, path?: string, ...pathSegments: string[]): DocumentReference<AppModelType, DbModelType>;

パラメーター

パラメータータイプ説明
参照CollectionReference <AppModelType, DbModelType> A reference to a collection.
パスA slash-separated path to a document. Has to be omitted to use auto-genrated IDs.
pathSegments弦[] Additional path segments that will be applied relative to the first argument.

戻り値:

DocumentReference <AppModelType, DbModelType>

The DocumentReference instance.

例外

If the final path has an odd number of segments and does not point to a document.

doc(reference, path, pathSegments)

Gets a DocumentReference instance that refers to a document within reference at the specified relative path.

サイン:

export declare function doc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[]): DocumentReference<DocumentData, DocumentData>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to a Firestore document.
パスA slash-separated path to a document.
pathSegments弦[] Additional path segments that will be applied relative to the first argument.

戻り値:

DocumentReference < DocumentData , DocumentData >

The DocumentReference instance.

例外

If the final path has an odd number of segments and does not point to a document.

getDoc(reference)

Reads the document referred to by this DocumentReference

サイン:

export declare function getDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> The reference of the document to fetch.

戻り値:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

getDocFromCache(reference)

Reads the document referred to by this DocumentReference from cache. Returns an error if the document is not currently cached.

サイン:

export declare function getDocFromCache<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType>

戻り値:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

getDocFromServer(reference)

Reads the document referred to by this DocumentReference from the server. Returns an error if the network is not available.

サイン:

export declare function getDocFromServer<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>): Promise<DocumentSnapshot<AppModelType, DbModelType>>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType>

戻り値:

Promise< DocumentSnapshot <AppModelType, DbModelType>>

A Promise resolved with a DocumentSnapshot containing the current document contents.

onSnapshot(reference, observer)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, observer: {
    next?: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
観察者{ next?: (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, options, observer)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, options: SnapshotListenOptions, observer: {
    next?: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void;
    error?: (error: FirestoreError) => void;
    complete?: () => void;
}): Unsubscribe;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
options SnapshotListenOptions Options controlling the listen behavior.
観察者{ next?: (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void; error?: (error: FirestoreError ) => void; complete?: () => void; } A single object containing next and error callbacks.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, onNext, onError, onCompletion)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
onNext (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new DocumentSnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
完了時に() => void Can be provided, but will not be called since streams are never ending.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

onSnapshot(reference, options, onNext, onError, onCompletion)

Attaches a listener for DocumentSnapshot events. You may either pass individual onNext and onError callbacks or pass a single observer object with next and error callbacks.

NOTE: Although an onCompletion callback can be provided, it will never be called because the snapshot stream is never-ending.

サイン:

export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void): Unsubscribe;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to listen to.
options SnapshotListenOptions Options controlling the listen behavior.
onNext (snapshot: DocumentSnapshot <AppModelType, DbModelType>) => void A callback to be called every time a new DocumentSnapshot is available.
onError (error: FirestoreError ) => void A callback to be called if the listen fails or is cancelled. No further callbacks will occur.
完了時に() => void Can be provided, but will not be called since streams are never ending.

戻り値:

購読を解除する

An unsubscribe function that can be called to cancel the snapshot listener.

setDoc(reference, data)

Writes to the document referred to by this DocumentReference 。 If the document does not yet exist, it will be created.

サイン:

export declare function setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>): Promise<void>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to write.
データWithFieldValue <AppModelType> A map of the fields and values for the document.

戻り値:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

setDoc(reference, data, options)

Writes to the document referred to by the specified DocumentReference 。 If the document does not yet exist, it will be created. If you provide merge or mergeFields , the provided data can be merged into an existing document.

サイン:

export declare function setDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: PartialWithFieldValue<AppModelType>, options: SetOptions): Promise<void>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to write.
データPartialWithFieldValue <AppModelType> A map of the fields and values for the document.
options SetOptions An object to configure the set behavior.

戻り値:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

updateDoc(reference, data)

Updates fields in the document referred to by the specified DocumentReference 。 The update will fail if applied to a document that does not exist.

サイン:

export declare function updateDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, data: UpdateData<DbModelType>): Promise<void>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to update.
データUpdateData <DbModelType> An object containing the fields and values with which to update the document. Fields can contain dots to reference nested fields within the document.

戻り値:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

updateDoc(reference, field, value, moreFieldsAndValues)

Updates fields in the document referred to by the specified DocumentReference The update will fail if applied to a document that does not exist.

Nested fields can be updated by providing dot-separated field path strings or by providing FieldPath objects.

サイン:

export declare function updateDoc<AppModelType, DbModelType extends DocumentData>(reference: DocumentReference<AppModelType, DbModelType>, field: string | FieldPath, value: unknown, ...moreFieldsAndValues: unknown[]): Promise<void>;

パラメーター

パラメータータイプ説明
参照DocumentReference <AppModelType, DbModelType> A reference to the document to update.
分野string | FieldPath The first field to update.
価値未知The first value.
moreFieldsAndValues未知[] Additional key value pairs.

戻り値:

Promise<void>

A Promise resolved once the data has been successfully written to the backend (note that it won't resolve while you're offline).

function(settings, ...)

memoryLocalCache(settings)

Creates an instance of MemoryLocalCache 。 The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

サイン:

export declare function memoryLocalCache(settings?: MemoryCacheSettings): MemoryLocalCache;

パラメーター

パラメータータイプ説明
設定MemoryCacheSettings

戻り値:

MemoryLocalCache

memoryLruGarbageCollector(settings)

Creates an instance of MemoryLruGarbageCollector

A target size can be specified as part of the setting parameter. The collector will start deleting documents once the cache size exceeds the given size. The default cache size is 40MB (40 * 1024 * 1024 bytes).

サイン:

export declare function memoryLruGarbageCollector(settings?: {
    cacheSizeBytes?: number;
}): MemoryLruGarbageCollector;

パラメーター

パラメータータイプ説明
設定{ cacheSizeBytes?: number; }

戻り値:

MemoryLruGarbageCollector

persistentLocalCache(settings)

Creates an instance of PersistentLocalCache 。 The instance can be set to FirestoreSettings.cache to tell the SDK which cache layer to use.

Persistent cache cannot be used in a Node.js environment.

サイン:

export declare function persistentLocalCache(settings?: PersistentCacheSettings): PersistentLocalCache;

パラメーター

パラメータータイプ説明
設定PersistentCacheSettings

戻り値:

PersistentLocalCache

persistentSingleTabManager(settings)

Creates an instance of PersistentSingleTabManager

サイン:

export declare function persistentSingleTabManager(settings: PersistentSingleTabManagerSettings | undefined): PersistentSingleTabManager;

パラメーター

パラメータータイプ説明
設定PersistentSingleTabManagerSettings |未定義Configures the created tab manager.

戻り値:

PersistentSingleTabManager

function(snapshot, ...)

endAt(snapshot)

Creates a QueryEndAtConstraint that modifies the result set to end at the provided document (inclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

サイン:

export declare function endAt<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryEndAtConstraint;

パラメーター

パラメータータイプ説明
スナップショットDocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to end at.

戻り値:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

endBefore(snapshot)

Creates a QueryEndAtConstraint that modifies the result set to end before the provided document (exclusive). The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

サイン:

export declare function endBefore<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryEndAtConstraint;

パラメーター

パラメータータイプ説明
スナップショットDocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to end before.

戻り値:

QueryEndAtConstraint

A QueryEndAtConstraint to pass to query()

startAfter(snapshot)

Creates a QueryStartAtConstraint that modifies the result set to start after the provided document (exclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query.

サイン:

export declare function startAfter<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryStartAtConstraint;

パラメーター

パラメータータイプ説明
スナップショットDocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to start after.

戻り値:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

startAt(snapshot)

Creates a QueryStartAtConstraint that modifies the result set to start at the provided document (inclusive). The starting position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of this query.

サイン:

export declare function startAt<AppModelType, DbModelType extends DocumentData>(snapshot: DocumentSnapshot<AppModelType, DbModelType>): QueryStartAtConstraint;

パラメーター

パラメータータイプ説明
スナップショットDocumentSnapshot <AppModelType, DbModelType> The snapshot of the document to start at.

戻り値:

QueryStartAtConstraint

A QueryStartAtConstraint to pass to query()

CACHE_SIZE_UNLIMITED

Constant used to indicate the LRU garbage collection should be disabled. Set this value as the cacheSizeBytes on the settings passed to the Firestore instance.

サイン:

CACHE_SIZE_UNLIMITED = -1

AddPrefixToKeys

Returns a new map where every key is prefixed with the outer key appended to a dot.

サイン:

export declare type AddPrefixToKeys<Prefix extends string, T extends Record<string, unknown>> = {
    [K in keyof T & string as `${Prefix}.${K}`]+?: string extends K ? any : T[K];
};

AggregateFieldType

The union of all AggregateField types that are supported by Firestore.

サイン:

export declare type AggregateFieldType = ReturnType<typeof sum> | ReturnType<typeof average> | ReturnType<typeof count>;

AggregateSpecData

A type whose keys are taken from an AggregateSpec , and whose values are the result of the aggregation performed by the corresponding AggregateField from the input AggregateSpec

サイン:

export declare type AggregateSpecData<T extends AggregateSpec> = {
    [P in keyof T]: T[P] extends AggregateField<infer U> ? U : never;
};

AggregateType

Union type representing the aggregate type to be performed.

サイン:

export declare type AggregateType = 'count' | 'avg' | 'sum';

ChildUpdateFields

Helper for calculating the nested fields for a given type T1. This is needed to distribute union types such as undefined | {...} (happens for optional props) or {a: A} | {b: B}

In this use case, V is used to distribute the union types of T[K] on Record , since T[K] is evaluated as an expression and not distributed.

See https://www.typescriptlang.org/docs/handbook/advanced-types.html#distributive-conditional-types

サイン:

export declare type ChildUpdateFields<K extends string, V> = V extends Record<string, unknown> ? AddPrefixToKeys<K, UpdateData<V>> : never;

DocumentChangeType

The type of a DocumentChange may be 'added', 'removed', or 'modified'.

サイン:

export declare type DocumentChangeType = 'added' | 'removed' | 'modified';

FirestoreErrorCode

The set of Firestore status codes. The codes are the same at the ones exposed by gRPC here: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md

Possible values: - 'cancelled': The operation was cancelled (typically by the caller). - 'unknown': Unknown error or an error from a different error domain. - 'invalid-argument': Client specified an invalid argument. Note that this differs from 'failed-precondition'. 'invalid-argument' indicates arguments that are problematic regardless of the state of the system (eg an invalid field name). - 'deadline-exceeded': Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire. - 'not-found': Some requested document was not found. - 'already-exists': Some document that we attempted to create already exists. - 'permission-denied': The caller does not have permission to execute the specified operation. - 'resource-exhausted': Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space. - 'failed-precondition': Operation was rejected because the system is not in a state required for the operation's execution. - 'aborted': The operation was aborted, typically due to a concurrency issue like transaction aborts, etc. - 'out-of-range': Operation was attempted past the valid range. - 'unimplemented': Operation is not implemented or not supported/enabled. - 'internal': Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken. - 'unavailable': The service is currently unavailable. This is most likely a transient condition and may be corrected by retrying with a backoff. - 'data-loss': Unrecoverable data loss or corruption. - 'unauthenticated': The request does not have valid authentication credentials for the operation.

サイン:

export declare type FirestoreErrorCode = 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';

FirestoreLocalCache

Union type from all supported SDK cache layer.

サイン:

export declare type FirestoreLocalCache = MemoryLocalCache | PersistentLocalCache;

ListenSource

Describe the source a query listens to.

Set to default to listen to both cache and server changes. Set to cache to listen to changes in cache only.

サイン:

export declare type ListenSource = 'default' | 'cache';

MemoryGarbageCollector

Union type from all support gabage collectors for memory local cache.

サイン:

export declare type MemoryGarbageCollector = MemoryEagerGarbageCollector | MemoryLruGarbageCollector;

NestedUpdateFields

For each field (eg 'bar'), find all nested keys (eg { 'bar.baz': T1, 'bar.qux': T2 } )。 Intersect them together to make a single map containing all possible keys that are all marked as optional

サイン:

export declare type NestedUpdateFields<T extends Record<string, unknown>> = UnionToIntersection<{
    [K in keyof T & string]: ChildUpdateFields<K, T[K]>;
}[keyof T & string]>;

OrderByDirection

The direction of a orderBy() clause is specified as 'desc' or 'asc' (descending or ascending).

サイン:

export declare type OrderByDirection = 'desc' | 'asc';

PartialWithFieldValue

Similar to Typescript's Partial<T> , but allows nested fields to be omitted and FieldValues to be passed in as property values.

サイン:

export declare type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T extends {} ? {
    [K in keyof T]?: PartialWithFieldValue<T[K]> | FieldValue;
} : never);

PersistentTabManager

A union of all available tab managers.

サイン:

export declare type PersistentTabManager = PersistentSingleTabManager | PersistentMultipleTabManager;

原生的

Primitive types.

サイン:

export declare type Primitive = string | number | boolean | undefined | null;

QueryConstraintType

Describes the different query constraints available in this SDK.

サイン:

export declare type QueryConstraintType = 'where' | 'orderBy' | 'limit' | 'limitToLast' | 'startAt' | 'startAfter' | 'endAt' | 'endBefore';

QueryFilterConstraint

QueryFilterConstraint is a helper union type that represents QueryFieldFilterConstraint and QueryCompositeFilterConstraint

サイン:

export declare type QueryFilterConstraint = QueryFieldFilterConstraint | QueryCompositeFilterConstraint;

QueryNonFilterConstraint

QueryNonFilterConstraint is a helper union type that represents QueryConstraints which are used to narrow or order the set of documents, but that do not explicitly filter on a document field. QueryNonFilterConstraint s are created by invoking orderBy() , startAt() , startAfter() , endBefore() , endAt() , limit() or limitToLast() and can then be passed to query() to create a new query instance that also contains the QueryConstraint

サイン:

export declare type QueryNonFilterConstraint = QueryOrderByConstraint | QueryLimitConstraint | QueryStartAtConstraint | QueryEndAtConstraint;

SetOptions

An options object that configures the behavior of setDoc() , and calls. These calls can be configured to perform granular merges instead of overwriting the target documents in their entirety by providing a SetOptions with merge: true

サイン:

export declare type SetOptions = {
    readonly merge?: boolean;
} | {
    readonly mergeFields?: Array<string | FieldPath>;
};

TaskState

Represents the state of bundle loading tasks.

Both 'Error' and 'Success' are sinking state: task will abort or complete and there will be no more updates after they are reported.

サイン:

export declare type TaskState = 'Error' | 'Running' | 'Success';

UnionToIntersection

Given a union type U = T1 | T2 | ... , returns an intersected type (T1 & T2 & ...)

Uses distributive conditional types and inference from conditional types. This works because multiple candidates for the same type variable in contra-variant positions causes an intersection type to be inferred. https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-inference-in-conditional-types https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection -タイプ

サイン:

export declare type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;

UpdateData

Update data (for use with updateDoc() ) that consists of field paths (eg 'foo' or 'foo.baz') mapped to values. Fields that contain dots reference nested fields within the document. FieldValues can be passed in as property values.

サイン:

export declare type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
    [K in keyof T]?: UpdateData<T[K]> | FieldValue;
} & NestedUpdateFields<T> : Partial<T>;

WhereFilterOp

Filter conditions in a where() clause are specified using the strings '&lt;', '&lt;=', '==', '!=', '&gt;=', '&gt;', 'array-contains', 'in', 'array-contains-any', and 'not-in'.

サイン:

export declare type WhereFilterOp = '<' | '<=' | '==' | '!=' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any' | 'not-in';

WithFieldValue

Allows FieldValues to be passed in as a property value while maintaining type safety.

サイン:

export declare type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
    [K in keyof T]: WithFieldValue<T[K]> | FieldValue;
} : never);