firebase-admin.firestore package

外部 API 重新匯出

為方便起見,下列外部定義的 API 會從這個模組進入點重新匯出。

符號 說明
BulkWriter 來自 @google-cloud/firestore 套件的 BulkWriter 類型。
AggregateField 來自 @google-cloud/firestore 套件的 AggregateField 類型。
BulkWriterOptions 來自 @google-cloud/firestore 套件的 BulkWriterOptions 類型。
BundleBuilder 來自 @google-cloud/firestore 套件的 BundleBuilder 類型。
集合群組 來自 @google-cloud/firestore 套件的 CollectionGroup 類型。
CollectionReference 來自 @google-cloud/firestore 套件的 CollectionReference 類型。
文件變更 來自 @google-cloud/firestore 套件的 DocumentChange 類型。
DocumentData 來自 @google-cloud/firestore 套件的 DocumentData 類型。
DocumentReference 來自 @google-cloud/firestore 套件的 DocumentReference 類型。
DocumentSnapshot 來自 @google-cloud/firestore 套件的 DocumentSnapshot 類型。
FieldPath 來自 @google-cloud/firestore 套件的 FieldPath 類型。
欄位值 來自 @google-cloud/firestore 套件的 FieldValue 類型。
篩選 來自 @google-cloud/firestore 套件的 Filter 類型。
Firestore 來自 @google-cloud/firestore 套件的 Firestore 類型。
FirestoreDataConverter 來自 @google-cloud/firestore 套件的 FirestoreDataConverter 類型。
GeoPoint 來自 @google-cloud/firestore 套件的 GeoPoint 類型。
GrpcStatus 來自 @google-cloud/firestore 套件的 GrpcStatus 類型。
先決條件 來自 @google-cloud/firestore 套件的 Precondition 類型。
查詢 來自 @google-cloud/firestore 套件的 Query 類型。
QueryDocumentSnapshot 來自 @google-cloud/firestore 套件的 QueryDocumentSnapshot 類型。
查詢分區 來自 @google-cloud/firestore 套件的 QueryPartition 類型。
查詢快照 來自 @google-cloud/firestore 套件的 QuerySnapshot 類型。
讀取選項 來自 @google-cloud/firestore 套件的 ReadOptions 類型。
SetOptions 來自 @google-cloud/firestore 套件的 SetOptions 類型。
時間戳記 來自 @google-cloud/firestore 套件的 Timestamp 類型。
交易 來自 @google-cloud/firestore 套件的 Transaction 類型。
WriteBatch 來自 @google-cloud/firestore 套件的 WriteBatch 類型。
WriteResult 來自 @google-cloud/firestore 套件的 WriteResult 類型。
setLogFunction @google-cloud/firestore 套件中的 setLogFunction 函式。

Cloud Firestore

函式

函式 說明
getFirestore() 取得預設應用程式的預設 Firestore 服務。
getFirestore(應用程式) 取得指定應用程式的預設 Firestore 服務。
getFirestore(databaseId) (Beta 版) 取得預設應用程式指定的 Firestore 服務。
getFirestore(應用程式, 資料庫 ID) (Beta 版) 取得指定應用程式的具名 Firestore 服務。
initializeFirestore(應用程式, 設定) 取得指定應用程式的預設 Firestore 服務,傳送額外參數至其建構函式。
初始化 Firestore(應用程式, 設定, 資料庫 ID) (Beta 版) 取得特定應用程式的具名 Firestore 服務,傳送額外參數至其建構函式。

介面

介面 說明
Firestore 設定 要傳遞至 Firestore 建構函式的設定。

getFirestore()

取得預設應用程式的預設 Firestore 服務。

簽名:

export declare function getFirestore(): Firestore;

傳回:

Firestore

預設應用程式的預設 Firestore 服務。

範例

// Get the default Firestore service for the default app
const defaultFirestore = getFirestore();

getFirestore(應用程式)

取得指定應用程式的預設 Firestore 服務。

簽名:

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

參數

參數 類型 說明
app 應用程式 要傳回哪個 Firestore 服務。

傳回:

Firestore

與所提供應用程式相關聯的預設 Firestore 服務。

範例

// Get the default Firestore service for a specific app
const otherFirestore = getFirestore(app);

getFirestore(databaseId)

這個 API 目前可供開發人員預覽,並可能會根據收到的意見回饋有所調整。請勿在正式環境中使用這個 API。

取得預設應用程式的名稱 Firestore 服務。

簽名:

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

參數

參數 類型 說明
資料庫 ID 字串 要傳回的資料庫名稱。

傳回:

Firestore

預設應用程式的名稱 Firestore 服務。

範例

// Get the Firestore service for a named database and default app
const otherFirestore = getFirestore('otherDb');

getFirestore(應用程式, 資料庫 ID)

這個 API 目前可供開發人員預覽,並可能會根據收到的意見回饋有所調整。請勿在正式環境中使用這個 API。

取得指定應用程式的具名 Firestore 服務。

簽名:

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

參數

參數 類型 說明
app 應用程式 要傳回哪個 Firestore 服務。
資料庫 ID 字串 要傳回的資料庫名稱。

傳回:

Firestore

與所提供應用程式相關聯的指定 Firestore 服務。

範例

// Get the Firestore service for a named database and specific app.
const otherFirestore = getFirestore('otherDb');

InitialFirestore(應用程式, 設定)

取得指定應用程式的預設 Firestore 服務,傳送額外參數至其建構函式。

簽名:

export declare function initializeFirestore(app: App, settings?: FirestoreSettings): Firestore;

參數

參數 類型 說明
app 應用程式 要傳回哪個 Firestore 服務。
設定 Firestore 設定 要傳遞至建構函式的設定物件。

傳回:

Firestore

與提供的應用程式和設定相關聯的預設 Firestore 服務。

範例

// Get the Firestore service for a specific app, require HTTP/1.1 REST transport
const otherFirestore = initializeFirestore(app, {preferRest: true});

initializeFirestore(應用程式, 設定, 資料庫 ID)

這個 API 目前可供開發人員預覽,並可能會根據收到的意見回饋有所調整。請勿在正式環境中使用這個 API。

取得指定應用程式的命名 Firestore 服務,並將額外參數傳送至其建構函式。

簽名:

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

參數

參數 類型 說明
app 應用程式 要傳回哪個 Firestore 服務。
設定 Firestore 設定 要傳遞至建構函式的設定物件。
資料庫 ID 字串 要傳回的資料庫名稱。

傳回:

Firestore

與提供的應用程式和設定相關聯的已命名 Firestore 服務。

範例

// Get the Firestore service for a specific app, require HTTP/1.1 REST transport
const otherFirestore = initializeFirestore(app, {preferRest: true}, 'otherDb');