firebase-rest-firestore 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +431 -0
- package/dist/cjs/index.d.ts +59 -0
- package/dist/cjs/index.js +388 -0
- package/dist/client.d.ts +68 -0
- package/dist/client.js +209 -0
- package/dist/esm/index.d.ts +59 -0
- package/dist/esm/index.js +349 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +34 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.js +2 -0
- package/dist/utils/auth.d.ts +13 -0
- package/dist/utils/auth.js +90 -0
- package/dist/utils/converter.d.ts +27 -0
- package/dist/utils/converter.js +113 -0
- package/dist/utils/path.d.ts +13 -0
- package/dist/utils/path.js +25 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# Firebase REST Firestore
|
|
2
|
+
|
|
3
|
+
Firebase Firestore REST API client for Edge runtime environments like Cloudflare Workers and Vercel Edge Functions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Works in Edge runtime environments where Firebase Admin SDK is not available
|
|
8
|
+
- Full CRUD operations support
|
|
9
|
+
- TypeScript support
|
|
10
|
+
- Token caching for better performance
|
|
11
|
+
- Simple and intuitive API
|
|
12
|
+
- Explicit configuration without hidden environment variable dependencies
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install firebase-rest-firestore
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Basic usage with explicit configuration
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createFirestoreClient } from "firebase-rest-firestore";
|
|
26
|
+
|
|
27
|
+
// Create a client with your configuration
|
|
28
|
+
const firestore = createFirestoreClient({
|
|
29
|
+
projectId: "your-project-id",
|
|
30
|
+
privateKey: "your-private-key",
|
|
31
|
+
clientEmail: "your-client-email",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Create a document
|
|
35
|
+
const game = await firestore.create("games", {
|
|
36
|
+
name: "New Game",
|
|
37
|
+
createdAt: new Date(),
|
|
38
|
+
score: 100,
|
|
39
|
+
active: true,
|
|
40
|
+
});
|
|
41
|
+
console.log("Created game ID:", game.id);
|
|
42
|
+
|
|
43
|
+
// Get a document
|
|
44
|
+
const fetchedGame = await firestore.get("games", game.id);
|
|
45
|
+
console.log("Fetched game:", fetchedGame);
|
|
46
|
+
|
|
47
|
+
// Update a document
|
|
48
|
+
const updatedGame = await firestore.update("games", game.id, {
|
|
49
|
+
...fetchedGame,
|
|
50
|
+
name: "Updated Game Name",
|
|
51
|
+
updatedAt: new Date(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Query documents
|
|
55
|
+
const userGames = await firestore.query("games", {
|
|
56
|
+
where: [{ field: "score", op: "GREATER_THAN", value: 50 }],
|
|
57
|
+
orderBy: "createdAt",
|
|
58
|
+
limit: 10,
|
|
59
|
+
});
|
|
60
|
+
console.log("Games with score > 50:", userGames);
|
|
61
|
+
|
|
62
|
+
// Delete a document
|
|
63
|
+
await firestore.delete("games", game.id);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
The `FirestoreConfig` object requires the following properties:
|
|
69
|
+
|
|
70
|
+
| Property | Description |
|
|
71
|
+
| ----------- | ---------------------------- |
|
|
72
|
+
| projectId | Firebase project ID |
|
|
73
|
+
| privateKey | Service account private key |
|
|
74
|
+
| clientEmail | Service account client email |
|
|
75
|
+
|
|
76
|
+
## API Reference
|
|
77
|
+
|
|
78
|
+
### FirestoreClient
|
|
79
|
+
|
|
80
|
+
The main class for interacting with Firestore.
|
|
81
|
+
|
|
82
|
+
#### create(collectionName, data)
|
|
83
|
+
|
|
84
|
+
Creates a new document in the specified collection.
|
|
85
|
+
|
|
86
|
+
#### get(collectionName, documentId)
|
|
87
|
+
|
|
88
|
+
Retrieves a document by ID.
|
|
89
|
+
|
|
90
|
+
#### update(collectionName, documentId, data)
|
|
91
|
+
|
|
92
|
+
Updates an existing document.
|
|
93
|
+
|
|
94
|
+
#### delete(collectionName, documentId)
|
|
95
|
+
|
|
96
|
+
Deletes a document.
|
|
97
|
+
|
|
98
|
+
#### query(collectionName, options)
|
|
99
|
+
|
|
100
|
+
Queries documents in a collection with filtering, ordering, and pagination.
|
|
101
|
+
|
|
102
|
+
### createFirestoreClient(config)
|
|
103
|
+
|
|
104
|
+
Creates a new FirestoreClient instance with the provided configuration.
|
|
105
|
+
|
|
106
|
+
### loadConfigFromEnv()
|
|
107
|
+
|
|
108
|
+
Helper function to load configuration from environment variables.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
113
|
+
|
|
114
|
+
## エラーハンドリング
|
|
115
|
+
|
|
116
|
+
Firebase REST Firestore は、API リクエスト中にエラーが発生した場合、適切なエラーメッセージを含む例外をスローします。以下はエラーハンドリングの例です:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
try {
|
|
120
|
+
// ドキュメントの取得を試みる
|
|
121
|
+
const game = await firestore.get("games", "non-existent-id");
|
|
122
|
+
|
|
123
|
+
// ドキュメントが存在しない場合はnullが返される
|
|
124
|
+
if (game === null) {
|
|
125
|
+
console.log("ドキュメントが見つかりませんでした");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ドキュメントが存在する場合の処理
|
|
130
|
+
console.log("取得したゲーム:", game);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
// API呼び出し中のエラー(認証エラーやネットワークエラーなど)
|
|
133
|
+
console.error("Firestoreエラー:", error.message);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
一般的なエラーケース:
|
|
138
|
+
|
|
139
|
+
- 認証エラー(無効なクレデンシャル)
|
|
140
|
+
- ネットワークエラー
|
|
141
|
+
- 無効なクエリパラメータ
|
|
142
|
+
- Firestore のレート制限
|
|
143
|
+
|
|
144
|
+
## クエリオプションの詳細
|
|
145
|
+
|
|
146
|
+
`query`メソッドでは、以下のオプションを使用して Firestore のドキュメントをフィルタリング、ソート、ページネーションできます:
|
|
147
|
+
|
|
148
|
+
### where
|
|
149
|
+
|
|
150
|
+
複数のフィルター条件を指定できます。各条件は以下のプロパティを持つオブジェクトです:
|
|
151
|
+
|
|
152
|
+
- `field`: フィルタリングするフィールド名
|
|
153
|
+
- `op`: 比較演算子。以下の値が使用可能です:
|
|
154
|
+
- `EQUAL`: 等しい
|
|
155
|
+
- `NOT_EQUAL`: 等しくない
|
|
156
|
+
- `LESS_THAN`: より小さい
|
|
157
|
+
- `LESS_THAN_OR_EQUAL`: 以下
|
|
158
|
+
- `GREATER_THAN`: より大きい
|
|
159
|
+
- `GREATER_THAN_OR_EQUAL`: 以上
|
|
160
|
+
- `ARRAY_CONTAINS`: 配列に含まれる
|
|
161
|
+
- `IN`: 指定した値のいずれかに等しい
|
|
162
|
+
- `ARRAY_CONTAINS_ANY`: 配列が指定した値のいずれかを含む
|
|
163
|
+
- `NOT_IN`: 指定した値のいずれにも等しくない
|
|
164
|
+
- `value`: 比較する値
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// スコアが50より大きく、activeがtrueのゲームを検索
|
|
168
|
+
const games = await firestore.query("games", {
|
|
169
|
+
where: [
|
|
170
|
+
{ field: "score", op: "GREATER_THAN", value: 50 },
|
|
171
|
+
{ field: "active", op: "EQUAL", value: true },
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### orderBy
|
|
177
|
+
|
|
178
|
+
結果を並べ替えるフィールド名を指定します。デフォルトでは昇順(ASCENDING)でソートされます。
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
// 作成日時で並べ替え
|
|
182
|
+
const games = await firestore.query("games", {
|
|
183
|
+
orderBy: "createdAt",
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### limit
|
|
188
|
+
|
|
189
|
+
返される結果の最大数を指定します。
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// 最大10件のドキュメントを取得
|
|
193
|
+
const games = await firestore.query("games", {
|
|
194
|
+
limit: 10,
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### offset
|
|
199
|
+
|
|
200
|
+
結果のスキップ数を指定します。ページネーションに使用できます。
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
// 最初の20件をスキップして、次の10件を取得
|
|
204
|
+
const games = await firestore.query("games", {
|
|
205
|
+
offset: 20,
|
|
206
|
+
limit: 10,
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
複合クエリの例:
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
// アクティブなゲームをスコアの高い順に10件取得
|
|
214
|
+
const topGames = await firestore.query("games", {
|
|
215
|
+
where: [{ field: "active", op: "EQUAL", value: true }],
|
|
216
|
+
orderBy: "score", // スコアでソート
|
|
217
|
+
limit: 10,
|
|
218
|
+
});
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## 日本語ドキュメント
|
|
222
|
+
|
|
223
|
+
### 概要
|
|
224
|
+
|
|
225
|
+
Firebase Firestore REST API クライアントは、Cloudflare Workers や Vercel Edge Functions などのエッジランタイム環境向けに設計されています。Firebase Admin SDK が利用できない環境で Firestore を操作するための軽量なライブラリです。
|
|
226
|
+
|
|
227
|
+
### 特徴
|
|
228
|
+
|
|
229
|
+
- エッジランタイム環境での動作(Firebase Admin SDK が利用できない環境)
|
|
230
|
+
- 完全な CRUD 操作のサポート
|
|
231
|
+
- TypeScript サポート
|
|
232
|
+
- パフォーマンス向上のためのトークンキャッシュ
|
|
233
|
+
- シンプルで直感的な API
|
|
234
|
+
- 環境変数に依存しない明示的な設定
|
|
235
|
+
|
|
236
|
+
### インストール
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
npm install firebase-rest-firestore
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 基本的な使い方
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { createFirestoreClient } from "firebase-rest-firestore";
|
|
246
|
+
|
|
247
|
+
// 設定を指定してクライアントを作成
|
|
248
|
+
const firestore = createFirestoreClient({
|
|
249
|
+
projectId: "あなたのプロジェクトID",
|
|
250
|
+
privateKey: "サービスアカウントの秘密鍵",
|
|
251
|
+
clientEmail: "サービスアカウントのメールアドレス",
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// ドキュメントの作成
|
|
255
|
+
const game = await firestore.create("games", {
|
|
256
|
+
name: "新しいゲーム",
|
|
257
|
+
createdAt: new Date(),
|
|
258
|
+
score: 100,
|
|
259
|
+
active: true,
|
|
260
|
+
});
|
|
261
|
+
console.log("作成されたゲームID:", game.id);
|
|
262
|
+
|
|
263
|
+
// ドキュメントの取得
|
|
264
|
+
const fetchedGame = await firestore.get("games", game.id);
|
|
265
|
+
console.log("取得したゲーム:", fetchedGame);
|
|
266
|
+
|
|
267
|
+
// ドキュメントの更新
|
|
268
|
+
const updatedGame = await firestore.update("games", game.id, {
|
|
269
|
+
...fetchedGame,
|
|
270
|
+
name: "更新されたゲーム名",
|
|
271
|
+
updatedAt: new Date(),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// ドキュメントのクエリ
|
|
275
|
+
const userGames = await firestore.query("games", {
|
|
276
|
+
where: [{ field: "score", op: "GREATER_THAN", value: 50 }],
|
|
277
|
+
orderBy: "createdAt",
|
|
278
|
+
limit: 10,
|
|
279
|
+
});
|
|
280
|
+
console.log("スコアが50より大きいゲーム:", userGames);
|
|
281
|
+
|
|
282
|
+
// ドキュメントの削除
|
|
283
|
+
await firestore.delete("games", game.id);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## 制限事項とロードマップ
|
|
287
|
+
|
|
288
|
+
### 現在の制限事項
|
|
289
|
+
|
|
290
|
+
- **バッチ操作**: 現在のバージョンでは、複数のドキュメントを一度に操作するバッチ処理はサポートされていません。
|
|
291
|
+
- **トランザクション**: 原子的なトランザクション操作はサポートされていません。
|
|
292
|
+
- **リアルタイムリスナー**: REST API の性質上、リアルタイムのデータ同期はサポートされていません。
|
|
293
|
+
- **サブコレクション**: 現在のバージョンでは、ネストされたサブコレクションの直接的なサポートは限定的です。
|
|
294
|
+
|
|
295
|
+
### 将来のロードマップ
|
|
296
|
+
|
|
297
|
+
以下の機能は将来のバージョンで実装予定です:
|
|
298
|
+
|
|
299
|
+
- バッチ操作のサポート
|
|
300
|
+
- 基本的なトランザクションのサポート
|
|
301
|
+
- サブコレクションの改善されたサポート
|
|
302
|
+
- より詳細なクエリオプション(複合インデックスなど)
|
|
303
|
+
- パフォーマンス最適化
|
|
304
|
+
|
|
305
|
+
機能リクエストやバグ報告は、GitHub の Issue でお知らせください。
|
|
306
|
+
|
|
307
|
+
## エッジランタイムでの使用例
|
|
308
|
+
|
|
309
|
+
### Cloudflare Workers
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// wrangler.toml に以下の環境変数を設定してください
|
|
313
|
+
// FIREBASE_PROJECT_ID
|
|
314
|
+
// FIREBASE_PRIVATE_KEY
|
|
315
|
+
// FIREBASE_CLIENT_EMAIL
|
|
316
|
+
|
|
317
|
+
import { createFirestoreClient } from "firebase-rest-firestore";
|
|
318
|
+
|
|
319
|
+
export default {
|
|
320
|
+
async fetch(request, env, ctx) {
|
|
321
|
+
// 環境変数から設定を読み込む
|
|
322
|
+
const firestore = createFirestoreClient({
|
|
323
|
+
projectId: env.FIREBASE_PROJECT_ID,
|
|
324
|
+
privateKey: env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, "\n"),
|
|
325
|
+
clientEmail: env.FIREBASE_CLIENT_EMAIL,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
const url = new URL(request.url);
|
|
329
|
+
const path = url.pathname;
|
|
330
|
+
|
|
331
|
+
// APIエンドポイントの例
|
|
332
|
+
if (path === "/api/games" && request.method === "GET") {
|
|
333
|
+
try {
|
|
334
|
+
// アクティブなゲームを取得
|
|
335
|
+
const games = await firestore.query("games", {
|
|
336
|
+
where: [{ field: "active", op: "EQUAL", value: true }],
|
|
337
|
+
limit: 10,
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
return new Response(JSON.stringify(games), {
|
|
341
|
+
headers: { "Content-Type": "application/json" },
|
|
342
|
+
});
|
|
343
|
+
} catch (error) {
|
|
344
|
+
return new Response(JSON.stringify({ error: error.message }), {
|
|
345
|
+
status: 500,
|
|
346
|
+
headers: { "Content-Type": "application/json" },
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return new Response("Not found", { status: 404 });
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Vercel Edge Functions
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
// .env.local に以下の環境変数を設定してください
|
|
360
|
+
// FIREBASE_PROJECT_ID
|
|
361
|
+
// FIREBASE_PRIVATE_KEY
|
|
362
|
+
// FIREBASE_CLIENT_EMAIL
|
|
363
|
+
|
|
364
|
+
import { createFirestoreClient } from "firebase-rest-firestore";
|
|
365
|
+
|
|
366
|
+
export const config = {
|
|
367
|
+
runtime: "edge",
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export default async function handler(request) {
|
|
371
|
+
// 環境変数から設定を読み込む
|
|
372
|
+
const firestore = createFirestoreClient({
|
|
373
|
+
projectId: process.env.FIREBASE_PROJECT_ID,
|
|
374
|
+
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, "\n"),
|
|
375
|
+
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
// 最新の10件のドキュメントを取得
|
|
380
|
+
const documents = await firestore.query("posts", {
|
|
381
|
+
orderBy: "createdAt",
|
|
382
|
+
limit: 10,
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
return new Response(JSON.stringify(documents), {
|
|
386
|
+
headers: { "Content-Type": "application/json" },
|
|
387
|
+
});
|
|
388
|
+
} catch (error) {
|
|
389
|
+
return new Response(JSON.stringify({ error: error.message }), {
|
|
390
|
+
status: 500,
|
|
391
|
+
headers: { "Content-Type": "application/json" },
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## パフォーマンスに関する注意点
|
|
398
|
+
|
|
399
|
+
### トークンキャッシュ
|
|
400
|
+
|
|
401
|
+
Firebase REST Firestore は、パフォーマンスを向上させるために JWT トークンをキャッシュします。デフォルトでは、トークンは 50 分間キャッシュされます(実際のトークン有効期限は 1 時間)。これにより、リクエストごとに新しいトークンを生成する必要がなくなり、API リクエストの速度が向上します。
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
// トークンは内部的にキャッシュされるため、
|
|
405
|
+
// 複数のリクエストでも認証のオーバーヘッドは最小限に抑えられます
|
|
406
|
+
const doc1 = await firestore.get("collection", "doc1");
|
|
407
|
+
const doc2 = await firestore.get("collection", "doc2");
|
|
408
|
+
const doc3 = await firestore.get("collection", "doc3");
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### クエリの最適化
|
|
412
|
+
|
|
413
|
+
大量のデータを扱う場合は、以下の点に注意してください:
|
|
414
|
+
|
|
415
|
+
1. **適切な制限を設定する**: 常に`limit`パラメータを使用して、返されるドキュメント数を制限してください。
|
|
416
|
+
|
|
417
|
+
2. **必要なフィールドのみをクエリする**: 将来のバージョンでは、特定のフィールドのみを取得する機能が追加される予定です。
|
|
418
|
+
|
|
419
|
+
3. **インデックスの作成**: 複雑なクエリを実行する場合は、Firebase コンソールで適切なインデックスを作成してください。
|
|
420
|
+
|
|
421
|
+
4. **ページネーションの使用**: 大量のデータを取得する場合は、`offset`と`limit`を組み合わせてページネーションを実装してください。
|
|
422
|
+
|
|
423
|
+
### エッジ環境での注意点
|
|
424
|
+
|
|
425
|
+
エッジ環境では、以下の点に注意してください:
|
|
426
|
+
|
|
427
|
+
1. **コールドスタート**: 初回実行時にはトークン生成のオーバーヘッドがあります。
|
|
428
|
+
|
|
429
|
+
2. **メモリ使用量**: 大量のデータを一度に処理する場合は、メモリ制限に注意してください。
|
|
430
|
+
|
|
431
|
+
3. **タイムアウト**: 長時間実行されるクエリは、エッジ環境のタイムアウト制限に達する可能性があります。
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firestoreの認証トークンを取得する関数
|
|
3
|
+
*/
|
|
4
|
+
export declare function getFirestoreToken(): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Firestoreクライアントクラス
|
|
7
|
+
*/
|
|
8
|
+
export declare class FirestoreClient {
|
|
9
|
+
private token;
|
|
10
|
+
private tokenExpiry;
|
|
11
|
+
/**
|
|
12
|
+
* 認証トークンを取得(キャッシュあり)
|
|
13
|
+
*/
|
|
14
|
+
private getToken;
|
|
15
|
+
/**
|
|
16
|
+
* Firestoreにドキュメントを作成
|
|
17
|
+
*/
|
|
18
|
+
create(collectionName: string, data: Record<string, any>): Promise<Record<string, any> & {
|
|
19
|
+
id: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* ドキュメントを取得
|
|
23
|
+
*/
|
|
24
|
+
get(collectionName: string, documentId: string): Promise<(Record<string, any> & {
|
|
25
|
+
id: string;
|
|
26
|
+
}) | null>;
|
|
27
|
+
/**
|
|
28
|
+
* ドキュメントを更新
|
|
29
|
+
*/
|
|
30
|
+
update(collectionName: string, documentId: string, data: Record<string, any>): Promise<Record<string, any> & {
|
|
31
|
+
id: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* ドキュメントを削除
|
|
35
|
+
*/
|
|
36
|
+
delete(collectionName: string, documentId: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* コレクションのドキュメントを検索
|
|
39
|
+
*/
|
|
40
|
+
query(collectionName: string, options?: {
|
|
41
|
+
where?: Array<{
|
|
42
|
+
field: string;
|
|
43
|
+
op: string;
|
|
44
|
+
value: any;
|
|
45
|
+
}>;
|
|
46
|
+
orderBy?: string;
|
|
47
|
+
limit?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
}): Promise<(Record<string, any> & {
|
|
50
|
+
id: string;
|
|
51
|
+
})[]>;
|
|
52
|
+
}
|
|
53
|
+
export declare const firestore: FirestoreClient;
|
|
54
|
+
export declare function saveToFirestore(collectionName: string, data: Record<string, any>): Promise<{
|
|
55
|
+
documentId: string;
|
|
56
|
+
result: Record<string, any> & {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
}>;
|