firebase-rest-firestore 0.1.0 → 0.2.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 CHANGED
@@ -10,6 +10,7 @@ Firebase Firestore REST API client for Edge runtime environments like Cloudflare
10
10
  - Token caching for better performance
11
11
  - Simple and intuitive API
12
12
  - Explicit configuration without hidden environment variable dependencies
13
+ - Firebase Admin SDK compatible interface (v0.2.0+)
13
14
 
14
15
  ## Installation
15
16
 
@@ -63,6 +64,83 @@ console.log("Games with score > 50:", userGames);
63
64
  await firestore.delete("games", game.id);
64
65
  ```
65
66
 
67
+ ### Firebase Admin SDK Compatible Interface (v0.2.0+)
68
+
69
+ From version 0.2.0, firebase-rest-firestore provides a Firebase Admin SDK compatible interface:
70
+
71
+ ```typescript
72
+ import { createFirestoreClient } from "firebase-rest-firestore";
73
+
74
+ // Create a client with your configuration
75
+ const firestore = createFirestoreClient({
76
+ projectId: "your-project-id",
77
+ privateKey: "your-private-key",
78
+ clientEmail: "your-client-email",
79
+ });
80
+
81
+ // Create a document with auto-generated ID
82
+ const gameRef = firestore.collection("games").doc();
83
+ await gameRef.set({
84
+ name: "New Game",
85
+ createdAt: new Date(),
86
+ score: 100,
87
+ active: true,
88
+ });
89
+ console.log("Created game ID:", gameRef.id);
90
+
91
+ // Create a document with specific ID
92
+ await firestore.collection("games").doc("game123").set({
93
+ name: "Specific Game",
94
+ createdAt: new Date(),
95
+ });
96
+
97
+ // Get a document
98
+ const gameDoc = await firestore.doc("games/game123").get();
99
+ if (gameDoc.exists) {
100
+ console.log("Fetched game:", gameDoc.data());
101
+ }
102
+
103
+ // Update a document
104
+ await firestore.collection("games").doc("game123").update({
105
+ name: "Updated Game Name",
106
+ updatedAt: new Date(),
107
+ });
108
+
109
+ // Query documents
110
+ const querySnapshot = await firestore
111
+ .collection("games")
112
+ .where("score", ">", 50)
113
+ .where("active", "==", true)
114
+ .orderBy("score", "desc")
115
+ .limit(10)
116
+ .get();
117
+
118
+ // Process query results
119
+ const games = [];
120
+ querySnapshot.forEach(doc => {
121
+ games.push({
122
+ id: doc.id,
123
+ ...doc.data(),
124
+ });
125
+ });
126
+ console.log("Games with score > 50:", games);
127
+
128
+ // Delete a document
129
+ await firestore.collection("games").doc("game123").delete();
130
+
131
+ // Working with subcollections
132
+ const commentRef = firestore
133
+ .collection("games")
134
+ .doc("game123")
135
+ .collection("comments")
136
+ .doc();
137
+
138
+ await commentRef.set({
139
+ text: "Great game!",
140
+ createdAt: new Date(),
141
+ });
142
+ ```
143
+
66
144
  ## Configuration
67
145
 
68
146
  The `FirestoreConfig` object requires the following properties:
@@ -107,64 +185,60 @@ Creates a new FirestoreClient instance with the provided configuration.
107
185
 
108
186
  Helper function to load configuration from environment variables.
109
187
 
110
- ## License
111
-
112
- MIT
113
-
114
- ## エラーハンドリング
188
+ ## Error Handling
115
189
 
116
- Firebase REST Firestore は、API リクエスト中にエラーが発生した場合、適切なエラーメッセージを含む例外をスローします。以下はエラーハンドリングの例です:
190
+ Firebase REST Firestore throws exceptions with appropriate error messages when API requests fail. Here's an example of error handling:
117
191
 
118
192
  ```typescript
119
193
  try {
120
- // ドキュメントの取得を試みる
194
+ // Try to get a document
121
195
  const game = await firestore.get("games", "non-existent-id");
122
196
 
123
- // ドキュメントが存在しない場合はnullが返される
197
+ // If document doesn't exist, null is returned
124
198
  if (game === null) {
125
- console.log("ドキュメントが見つかりませんでした");
199
+ console.log("Document not found");
126
200
  return;
127
201
  }
128
202
 
129
- // ドキュメントが存在する場合の処理
130
- console.log("取得したゲーム:", game);
203
+ // Process document if it exists
204
+ console.log("Fetched game:", game);
131
205
  } catch (error) {
132
- // API呼び出し中のエラー(認証エラーやネットワークエラーなど)
133
- console.error("Firestoreエラー:", error.message);
206
+ // Handle API errors (authentication, network, etc.)
207
+ console.error("Firestore error:", error.message);
134
208
  }
135
209
  ```
136
210
 
137
- 一般的なエラーケース:
211
+ Common error cases:
138
212
 
139
- - 認証エラー(無効なクレデンシャル)
140
- - ネットワークエラー
141
- - 無効なクエリパラメータ
142
- - Firestore のレート制限
213
+ - Authentication errors (invalid credentials)
214
+ - Network errors
215
+ - Invalid query parameters
216
+ - Firestore rate limits
143
217
 
144
- ## クエリオプションの詳細
218
+ ## Query Options Details
145
219
 
146
- `query`メソッドでは、以下のオプションを使用して Firestore のドキュメントをフィルタリング、ソート、ページネーションできます:
220
+ The `query` method supports the following options for filtering, sorting, and paginating Firestore documents:
147
221
 
148
222
  ### where
149
223
 
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`: 比較する値
224
+ Specify multiple filter conditions. Each condition is an object with the following properties:
225
+
226
+ - `field`: The field name to filter on
227
+ - `op`: The comparison operator. Available values:
228
+ - `EQUAL`: Equal to
229
+ - `NOT_EQUAL`: Not equal to
230
+ - `LESS_THAN`: Less than
231
+ - `LESS_THAN_OR_EQUAL`: Less than or equal to
232
+ - `GREATER_THAN`: Greater than
233
+ - `GREATER_THAN_OR_EQUAL`: Greater than or equal to
234
+ - `ARRAY_CONTAINS`: Array contains
235
+ - `IN`: Equal to any of the specified values
236
+ - `ARRAY_CONTAINS_ANY`: Array contains any of the specified values
237
+ - `NOT_IN`: Not equal to any of the specified values
238
+ - `value`: The value to compare against
165
239
 
166
240
  ```typescript
167
- // スコアが50より大きく、activeがtrueのゲームを検索
241
+ // Query games with score > 50 and active = true
168
242
  const games = await firestore.query("games", {
169
243
  where: [
170
244
  { field: "score", op: "GREATER_THAN", value: 50 },
@@ -175,10 +249,10 @@ const games = await firestore.query("games", {
175
249
 
176
250
  ### orderBy
177
251
 
178
- 結果を並べ替えるフィールド名を指定します。デフォルトでは昇順(ASCENDING)でソートされます。
252
+ Specifies the field name to sort results by. Results are sorted in ascending order by default.
179
253
 
180
254
  ```typescript
181
- // 作成日時で並べ替え
255
+ // Sort by creation time
182
256
  const games = await firestore.query("games", {
183
257
  orderBy: "createdAt",
184
258
  });
@@ -186,10 +260,10 @@ const games = await firestore.query("games", {
186
260
 
187
261
  ### limit
188
262
 
189
- 返される結果の最大数を指定します。
263
+ Limits the maximum number of results returned.
190
264
 
191
265
  ```typescript
192
- // 最大10件のドキュメントを取得
266
+ // Get at most 10 documents
193
267
  const games = await firestore.query("games", {
194
268
  limit: 10,
195
269
  });
@@ -197,49 +271,203 @@ const games = await firestore.query("games", {
197
271
 
198
272
  ### offset
199
273
 
200
- 結果のスキップ数を指定します。ページネーションに使用できます。
274
+ Specifies the number of results to skip. Useful for pagination.
201
275
 
202
276
  ```typescript
203
- // 最初の20件をスキップして、次の10件を取得
277
+ // Skip the first 20 results and get the next 10
204
278
  const games = await firestore.query("games", {
205
279
  offset: 20,
206
280
  limit: 10,
207
281
  });
208
282
  ```
209
283
 
210
- 複合クエリの例:
284
+ Example of a compound query:
211
285
 
212
286
  ```typescript
213
- // アクティブなゲームをスコアの高い順に10件取得
287
+ // Get top 10 active games by score
214
288
  const topGames = await firestore.query("games", {
215
289
  where: [{ field: "active", op: "EQUAL", value: true }],
216
- orderBy: "score", // スコアでソート
290
+ orderBy: "score", // Sort by score
217
291
  limit: 10,
218
292
  });
219
293
  ```
220
294
 
221
- ## 日本語ドキュメント
295
+ ## Edge Runtime Examples
222
296
 
223
- ### 概要
297
+ ### Cloudflare Workers
224
298
 
225
- Firebase Firestore REST API クライアントは、Cloudflare Workers や Vercel Edge Functions などのエッジランタイム環境向けに設計されています。Firebase Admin SDK が利用できない環境で Firestore を操作するための軽量なライブラリです。
299
+ ```typescript
300
+ // Set these environment variables in wrangler.toml
301
+ // FIREBASE_PROJECT_ID
302
+ // FIREBASE_PRIVATE_KEY
303
+ // FIREBASE_CLIENT_EMAIL
226
304
 
227
- ### 特徴
305
+ import { createFirestoreClient } from "firebase-rest-firestore";
306
+
307
+ export default {
308
+ async fetch(request, env, ctx) {
309
+ // Load configuration from environment variables
310
+ const firestore = createFirestoreClient({
311
+ projectId: env.FIREBASE_PROJECT_ID,
312
+ privateKey: env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, "\n"),
313
+ clientEmail: env.FIREBASE_CLIENT_EMAIL,
314
+ });
315
+
316
+ const url = new URL(request.url);
317
+ const path = url.pathname;
228
318
 
229
- - エッジランタイム環境での動作(Firebase Admin SDK が利用できない環境)
319
+ // Example API endpoint
320
+ if (path === "/api/games" && request.method === "GET") {
321
+ try {
322
+ // Get active games
323
+ const games = await firestore.query("games", {
324
+ where: [{ field: "active", op: "EQUAL", value: true }],
325
+ limit: 10,
326
+ });
327
+
328
+ return new Response(JSON.stringify(games), {
329
+ headers: { "Content-Type": "application/json" },
330
+ });
331
+ } catch (error) {
332
+ return new Response(JSON.stringify({ error: error.message }), {
333
+ status: 500,
334
+ headers: { "Content-Type": "application/json" },
335
+ });
336
+ }
337
+ }
338
+
339
+ return new Response("Not found", { status: 404 });
340
+ },
341
+ };
342
+ ```
343
+
344
+ ### Vercel Edge Functions
345
+
346
+ ```typescript
347
+ // Set these environment variables in .env.local
348
+ // FIREBASE_PROJECT_ID
349
+ // FIREBASE_PRIVATE_KEY
350
+ // FIREBASE_CLIENT_EMAIL
351
+
352
+ import { createFirestoreClient } from "firebase-rest-firestore";
353
+
354
+ export const config = {
355
+ runtime: "edge",
356
+ };
357
+
358
+ export default async function handler(request) {
359
+ // Load configuration from environment variables
360
+ const firestore = createFirestoreClient({
361
+ projectId: process.env.FIREBASE_PROJECT_ID,
362
+ privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, "\n"),
363
+ clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
364
+ });
365
+
366
+ try {
367
+ // Get the latest 10 documents
368
+ const documents = await firestore.query("posts", {
369
+ orderBy: "createdAt",
370
+ limit: 10,
371
+ });
372
+
373
+ return new Response(JSON.stringify(documents), {
374
+ headers: { "Content-Type": "application/json" },
375
+ });
376
+ } catch (error) {
377
+ return new Response(JSON.stringify({ error: error.message }), {
378
+ status: 500,
379
+ headers: { "Content-Type": "application/json" },
380
+ });
381
+ }
382
+ }
383
+ ```
384
+
385
+ ## Performance Considerations
386
+
387
+ ### Token Caching
388
+
389
+ Firebase REST Firestore caches JWT tokens to improve performance. By default, tokens are cached for 50 minutes (actual token expiry is 1 hour). This eliminates the need to generate a new token for each request, improving API request speed.
390
+
391
+ ```typescript
392
+ // Tokens are cached internally, so multiple requests
393
+ // have minimal authentication overhead
394
+ const doc1 = await firestore.get("collection", "doc1");
395
+ const doc2 = await firestore.get("collection", "doc2");
396
+ const doc3 = await firestore.get("collection", "doc3");
397
+ ```
398
+
399
+ ### Query Optimization
400
+
401
+ When dealing with large amounts of data, consider the following:
402
+
403
+ 1. **Set appropriate limits**: Always use the `limit` parameter to restrict the number of documents returned.
404
+
405
+ 2. **Query only needed fields**: Future versions will add support for retrieving only specific fields.
406
+
407
+ 3. **Create indexes**: For complex queries, create appropriate indexes in the Firebase console.
408
+
409
+ 4. **Use pagination**: When retrieving large datasets, implement pagination using `offset` and `limit`.
410
+
411
+ ### Edge Environment Considerations
412
+
413
+ In edge environments, be aware of:
414
+
415
+ 1. **Cold starts**: Initial execution has token generation overhead.
416
+
417
+ 2. **Memory usage**: Be mindful of memory limits when processing large amounts of data.
418
+
419
+ 3. **Timeouts**: Long-running queries may hit edge environment timeout limits.
420
+
421
+ ## Limitations and Roadmap
422
+
423
+ ### Current Limitations
424
+
425
+ - **Batch operations**: The current version does not support batch processing for operating on multiple documents at once.
426
+ - **Transactions**: Atomic transaction operations are not supported.
427
+ - **Real-time listeners**: Due to the nature of REST APIs, real-time data synchronization is not supported.
428
+ - **Subcollections**: The current version has limited direct support for nested subcollections.
429
+
430
+ ### Future Roadmap
431
+
432
+ The following features are planned for future versions:
433
+
434
+ - Batch operations support
435
+ - Basic transaction support
436
+ - Improved subcollection support
437
+ - More detailed query options (compound indexes, etc.)
438
+ - Performance optimizations
439
+
440
+ Please report feature requests and bugs via GitHub Issues.
441
+
442
+ ## License
443
+
444
+ MIT
445
+
446
+ ---
447
+
448
+ # Firebase REST Firestore (日本語ドキュメント)
449
+
450
+ Firebase Firestore REST API クライアントは、Cloudflare Workers や Vercel Edge Functions などのエッジランタイム環境向けに設計されています。
451
+
452
+ ## 特徴
453
+
454
+ - Firebase Admin SDK が利用できないエッジランタイム環境で動作
230
455
  - 完全な CRUD 操作のサポート
231
456
  - TypeScript サポート
232
457
  - パフォーマンス向上のためのトークンキャッシュ
233
458
  - シンプルで直感的な API
234
459
  - 環境変数に依存しない明示的な設定
460
+ - Firebase Admin SDK compatible interface (v0.2.0+)
235
461
 
236
- ### インストール
462
+ ## インストール
237
463
 
238
464
  ```bash
239
465
  npm install firebase-rest-firestore
240
466
  ```
241
467
 
242
- ### 基本的な使い方
468
+ ## 使い方
469
+
470
+ ### 基本的な使い方(明示的な設定)
243
471
 
244
472
  ```typescript
245
473
  import { createFirestoreClient } from "firebase-rest-firestore";
@@ -283,26 +511,233 @@ console.log("スコアが50より大きいゲーム:", userGames);
283
511
  await firestore.delete("games", game.id);
284
512
  ```
285
513
 
286
- ## 制限事項とロードマップ
514
+ ### Firebase Admin SDK 互換インターフェース (v0.2.0+)
287
515
 
288
- ### 現在の制限事項
516
+ バージョン 0.2.0 から、firebase-rest-firestore は Firebase Admin SDK と互換性のあるインターフェースを提供しています:
289
517
 
290
- - **バッチ操作**: 現在のバージョンでは、複数のドキュメントを一度に操作するバッチ処理はサポートされていません。
291
- - **トランザクション**: 原子的なトランザクション操作はサポートされていません。
292
- - **リアルタイムリスナー**: REST API の性質上、リアルタイムのデータ同期はサポートされていません。
293
- - **サブコレクション**: 現在のバージョンでは、ネストされたサブコレクションの直接的なサポートは限定的です。
518
+ ```typescript
519
+ import { createFirestoreClient } from "firebase-rest-firestore";
294
520
 
295
- ### 将来のロードマップ
521
+ // 設定を指定してクライアントを作成
522
+ const firestore = createFirestoreClient({
523
+ projectId: "あなたのプロジェクトID",
524
+ privateKey: "サービスアカウントの秘密鍵",
525
+ clientEmail: "サービスアカウントのメールアドレス",
526
+ });
296
527
 
297
- 以下の機能は将来のバージョンで実装予定です:
528
+ // 自動生成IDでドキュメントを作成
529
+ const gameRef = firestore.collection("games").doc();
530
+ await gameRef.set({
531
+ name: "新しいゲーム",
532
+ createdAt: new Date(),
533
+ score: 100,
534
+ active: true,
535
+ });
536
+ console.log("作成されたゲームID:", gameRef.id);
298
537
 
299
- - バッチ操作のサポート
300
- - 基本的なトランザクションのサポート
301
- - サブコレクションの改善されたサポート
302
- - より詳細なクエリオプション(複合インデックスなど)
303
- - パフォーマンス最適化
538
+ // 特定のIDでドキュメントを作成
539
+ await firestore.collection("games").doc("game123").set({
540
+ name: "特定のゲーム",
541
+ createdAt: new Date(),
542
+ });
304
543
 
305
- 機能リクエストやバグ報告は、GitHub の Issue でお知らせください。
544
+ // ドキュメントの取得
545
+ const gameDoc = await firestore.doc("games/game123").get();
546
+ if (gameDoc.exists) {
547
+ console.log("取得したゲーム:", gameDoc.data());
548
+ }
549
+
550
+ // ドキュメントの更新
551
+ await firestore.collection("games").doc("game123").update({
552
+ name: "更新されたゲーム名",
553
+ updatedAt: new Date(),
554
+ });
555
+
556
+ // ドキュメントのクエリ
557
+ const querySnapshot = await firestore
558
+ .collection("games")
559
+ .where("score", ">", 50)
560
+ .where("active", "==", true)
561
+ .orderBy("score", "desc")
562
+ .limit(10)
563
+ .get();
564
+
565
+ // クエリ結果の処理
566
+ const games = [];
567
+ querySnapshot.forEach(doc => {
568
+ games.push({
569
+ id: doc.id,
570
+ ...doc.data(),
571
+ });
572
+ });
573
+ console.log("スコアが50より大きいゲーム:", games);
574
+
575
+ // ドキュメントの削除
576
+ await firestore.collection("games").doc("game123").delete();
577
+
578
+ // サブコレクションの操作
579
+ const commentRef = firestore
580
+ .collection("games")
581
+ .doc("game123")
582
+ .collection("comments")
583
+ .doc();
584
+
585
+ await commentRef.set({
586
+ text: "素晴らしいゲーム!",
587
+ createdAt: new Date(),
588
+ });
589
+ ```
590
+
591
+ ## 設定
592
+
593
+ `FirestoreConfig`オブジェクトには以下のプロパティが必要です:
594
+
595
+ | プロパティ | 説明 |
596
+ | ----------- | ---------------------------------- |
597
+ | projectId | Firebase プロジェクト ID |
598
+ | privateKey | サービスアカウントの秘密鍵 |
599
+ | clientEmail | サービスアカウントのメールアドレス |
600
+
601
+ ## API リファレンス
602
+
603
+ ### FirestoreClient
604
+
605
+ Firestore と対話するためのメインクラスです。
606
+
607
+ #### create(collectionName, data)
608
+
609
+ 指定されたコレクションに新しいドキュメントを作成します。
610
+
611
+ #### get(collectionName, documentId)
612
+
613
+ ID によってドキュメントを取得します。
614
+
615
+ #### update(collectionName, documentId, data)
616
+
617
+ 既存のドキュメントを更新します。
618
+
619
+ #### delete(collectionName, documentId)
620
+
621
+ ドキュメントを削除します。
622
+
623
+ #### query(collectionName, options)
624
+
625
+ フィルタリング、並べ替え、ページネーションを使用してコレクション内のドキュメントをクエリします。
626
+
627
+ ### createFirestoreClient(config)
628
+
629
+ 提供された設定で新しい FirestoreClient インスタンスを作成します。
630
+
631
+ ### loadConfigFromEnv()
632
+
633
+ 環境変数から設定を読み込むためのヘルパー関数です。
634
+
635
+ ## エラーハンドリング
636
+
637
+ Firebase REST Firestore は、API リクエスト中にエラーが発生した場合、適切なエラーメッセージを含む例外をスローします。以下はエラーハンドリングの例です:
638
+
639
+ ```typescript
640
+ try {
641
+ // ドキュメントの取得を試みる
642
+ const game = await firestore.get("games", "non-existent-id");
643
+
644
+ // ドキュメントが存在しない場合はnullが返される
645
+ if (game === null) {
646
+ console.log("ドキュメントが見つかりませんでした");
647
+ return;
648
+ }
649
+
650
+ // ドキュメントが存在する場合の処理
651
+ console.log("取得したゲーム:", game);
652
+ } catch (error) {
653
+ // API呼び出し中のエラー(認証エラーやネットワークエラーなど)
654
+ console.error("Firestoreエラー:", error.message);
655
+ }
656
+ ```
657
+
658
+ 一般的なエラーケース:
659
+
660
+ - 認証エラー(無効なクレデンシャル)
661
+ - ネットワークエラー
662
+ - 無効なクエリパラメータ
663
+ - Firestore のレート制限
664
+
665
+ ## クエリオプションの詳細
666
+
667
+ `query`メソッドでは、以下のオプションを使用して Firestore のドキュメントをフィルタリング、ソート、ページネーションできます:
668
+
669
+ ### where
670
+
671
+ 複数のフィルター条件を指定できます。各条件は以下のプロパティを持つオブジェクトです:
672
+
673
+ - `field`: フィルタリングするフィールド名
674
+ - `op`: 比較演算子。以下の値が使用可能です:
675
+ - `EQUAL`: 等しい
676
+ - `NOT_EQUAL`: 等しくない
677
+ - `LESS_THAN`: より小さい
678
+ - `LESS_THAN_OR_EQUAL`: 以下
679
+ - `GREATER_THAN`: より大きい
680
+ - `GREATER_THAN_OR_EQUAL`: 以上
681
+ - `ARRAY_CONTAINS`: 配列に含まれる
682
+ - `IN`: 指定した値のいずれかに等しい
683
+ - `ARRAY_CONTAINS_ANY`: 配列が指定した値のいずれかを含む
684
+ - `NOT_IN`: 指定した値のいずれにも等しくない
685
+ - `value`: 比較する値
686
+
687
+ ```typescript
688
+ // スコアが50より大きく、activeがtrueのゲームを検索
689
+ const games = await firestore.query("games", {
690
+ where: [
691
+ { field: "score", op: "GREATER_THAN", value: 50 },
692
+ { field: "active", op: "EQUAL", value: true },
693
+ ],
694
+ });
695
+ ```
696
+
697
+ ### orderBy
698
+
699
+ 結果を並べ替えるフィールド名を指定します。デフォルトでは昇順(ASCENDING)でソートされます。
700
+
701
+ ```typescript
702
+ // 作成日時で並べ替え
703
+ const games = await firestore.query("games", {
704
+ orderBy: "createdAt",
705
+ });
706
+ ```
707
+
708
+ ### limit
709
+
710
+ 返される結果の最大数を指定します。
711
+
712
+ ```typescript
713
+ // 最大10件のドキュメントを取得
714
+ const games = await firestore.query("games", {
715
+ limit: 10,
716
+ });
717
+ ```
718
+
719
+ ### offset
720
+
721
+ 結果のスキップ数を指定します。ページネーションに使用できます。
722
+
723
+ ```typescript
724
+ // 最初の20件をスキップして、次の10件を取得
725
+ const games = await firestore.query("games", {
726
+ offset: 20,
727
+ limit: 10,
728
+ });
729
+ ```
730
+
731
+ 複合クエリの例:
732
+
733
+ ```typescript
734
+ // アクティブなゲームをスコアの高い順に10件取得
735
+ const topGames = await firestore.query("games", {
736
+ where: [{ field: "active", op: "EQUAL", value: true }],
737
+ orderBy: "score", // スコアでソート
738
+ limit: 10,
739
+ });
740
+ ```
306
741
 
307
742
  ## エッジランタイムでの使用例
308
743
 
@@ -429,3 +864,28 @@ const doc3 = await firestore.get("collection", "doc3");
429
864
  2. **メモリ使用量**: 大量のデータを一度に処理する場合は、メモリ制限に注意してください。
430
865
 
431
866
  3. **タイムアウト**: 長時間実行されるクエリは、エッジ環境のタイムアウト制限に達する可能性があります。
867
+
868
+ ## 制限事項とロードマップ
869
+
870
+ ### 現在の制限事項
871
+
872
+ - **バッチ操作**: 現在のバージョンでは、複数のドキュメントを一度に操作するバッチ処理はサポートされていません。
873
+ - **トランザクション**: 原子的なトランザクション操作はサポートされていません。
874
+ - **リアルタイムリスナー**: REST API の性質上、リアルタイムのデータ同期はサポートされていません。
875
+ - **サブコレクション**: 現在のバージョンでは、ネストされたサブコレクションの直接的なサポートは限定的です。
876
+
877
+ ### 将来のロードマップ
878
+
879
+ 以下の機能は将来のバージョンで実装予定です:
880
+
881
+ - バッチ操作のサポート
882
+ - 基本的なトランザクションのサポート
883
+ - サブコレクションの改善されたサポート
884
+ - より詳細なクエリオプション(複合インデックスなど)
885
+ - パフォーマンス最適化
886
+
887
+ 機能リクエストやバグ報告は、GitHub の Issue でお知らせください。
888
+
889
+ ## ライセンス
890
+
891
+ MIT