firebase-rest-firestore 0.1.0 → 0.2.1
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 +528 -66
- package/dist/client.d.ts +240 -0
- package/dist/client.js +461 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -6,15 +6,33 @@ export declare class FirestoreClient {
|
|
|
6
6
|
private token;
|
|
7
7
|
private tokenExpiry;
|
|
8
8
|
private config;
|
|
9
|
+
private configChecked;
|
|
9
10
|
/**
|
|
10
11
|
* コンストラクタ
|
|
11
12
|
* @param config Firestore設定オブジェクト
|
|
12
13
|
*/
|
|
13
14
|
constructor(config: FirestoreConfig);
|
|
15
|
+
/**
|
|
16
|
+
* 設定パラメータをチェック
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
private checkConfig;
|
|
14
20
|
/**
|
|
15
21
|
* 認証トークンを取得(キャッシュあり)
|
|
16
22
|
*/
|
|
17
23
|
private getToken;
|
|
24
|
+
/**
|
|
25
|
+
* コレクションリファレンスを取得
|
|
26
|
+
* @param path コレクションパス
|
|
27
|
+
* @returns CollectionReferenceインスタンス
|
|
28
|
+
*/
|
|
29
|
+
collection(path: string): CollectionReference;
|
|
30
|
+
/**
|
|
31
|
+
* ドキュメントリファレンスを取得
|
|
32
|
+
* @param path ドキュメントパス
|
|
33
|
+
* @returns DocumentReferenceインスタンス
|
|
34
|
+
*/
|
|
35
|
+
doc(path: string): DocumentReference;
|
|
18
36
|
/**
|
|
19
37
|
* Firestoreにドキュメントを作成
|
|
20
38
|
* @param collectionName コレクション名
|
|
@@ -60,6 +78,228 @@ export declare class FirestoreClient {
|
|
|
60
78
|
id: string;
|
|
61
79
|
})[]>;
|
|
62
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* コレクションリファレンスクラス
|
|
83
|
+
*/
|
|
84
|
+
export declare class CollectionReference {
|
|
85
|
+
private client;
|
|
86
|
+
private path;
|
|
87
|
+
private _queryConstraints;
|
|
88
|
+
constructor(client: FirestoreClient, path: string);
|
|
89
|
+
/**
|
|
90
|
+
* ドキュメントリファレンスを取得
|
|
91
|
+
* @param documentPath ドキュメントID(省略時は自動生成)
|
|
92
|
+
* @returns DocumentReferenceインスタンス
|
|
93
|
+
*/
|
|
94
|
+
doc(documentPath?: string): DocumentReference;
|
|
95
|
+
/**
|
|
96
|
+
* ドキュメントを追加(IDは自動生成)
|
|
97
|
+
* @param data ドキュメントデータ
|
|
98
|
+
* @returns 作成されたドキュメントのリファレンス
|
|
99
|
+
*/
|
|
100
|
+
add(data: Record<string, any>): Promise<DocumentReference>;
|
|
101
|
+
/**
|
|
102
|
+
* フィルター条件を追加
|
|
103
|
+
* @param fieldPath フィールドパス
|
|
104
|
+
* @param opStr 演算子
|
|
105
|
+
* @param value 値
|
|
106
|
+
* @returns Queryインスタンス
|
|
107
|
+
*/
|
|
108
|
+
where(fieldPath: string, opStr: string, value: any): Query;
|
|
109
|
+
/**
|
|
110
|
+
* 並べ替え条件を追加
|
|
111
|
+
* @param fieldPath フィールドパス
|
|
112
|
+
* @param directionStr 並べ替え方向('asc'または'desc')
|
|
113
|
+
* @returns Queryインスタンス
|
|
114
|
+
*/
|
|
115
|
+
orderBy(fieldPath: string, directionStr?: "asc" | "desc"): Query;
|
|
116
|
+
/**
|
|
117
|
+
* 取得件数の制限を設定
|
|
118
|
+
* @param limit 最大件数
|
|
119
|
+
* @returns Queryインスタンス
|
|
120
|
+
*/
|
|
121
|
+
limit(limit: number): Query;
|
|
122
|
+
/**
|
|
123
|
+
* スキップ件数を設定
|
|
124
|
+
* @param offset スキップ件数
|
|
125
|
+
* @returns Queryインスタンス
|
|
126
|
+
*/
|
|
127
|
+
offset(offset: number): Query;
|
|
128
|
+
/**
|
|
129
|
+
* クエリを実行
|
|
130
|
+
* @returns QuerySnapshotインスタンス
|
|
131
|
+
*/
|
|
132
|
+
get(): Promise<QuerySnapshot>;
|
|
133
|
+
/**
|
|
134
|
+
* ランダムなIDを生成
|
|
135
|
+
* @returns ランダムなID
|
|
136
|
+
*/
|
|
137
|
+
private _generateId;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* ドキュメントリファレンスクラス
|
|
141
|
+
*/
|
|
142
|
+
export declare class DocumentReference {
|
|
143
|
+
private client;
|
|
144
|
+
private collectionPath;
|
|
145
|
+
private docId;
|
|
146
|
+
constructor(client: FirestoreClient, collectionPath: string, docId: string);
|
|
147
|
+
/**
|
|
148
|
+
* ドキュメントIDを取得
|
|
149
|
+
*/
|
|
150
|
+
get id(): string;
|
|
151
|
+
/**
|
|
152
|
+
* ドキュメントのパスを取得
|
|
153
|
+
*/
|
|
154
|
+
get path(): string;
|
|
155
|
+
/**
|
|
156
|
+
* サブコレクションを取得
|
|
157
|
+
* @param collectionPath サブコレクション名
|
|
158
|
+
* @returns CollectionReferenceインスタンス
|
|
159
|
+
*/
|
|
160
|
+
collection(collectionPath: string): CollectionReference;
|
|
161
|
+
/**
|
|
162
|
+
* ドキュメントを取得
|
|
163
|
+
* @returns DocumentSnapshotインスタンス
|
|
164
|
+
*/
|
|
165
|
+
get(): Promise<DocumentSnapshot>;
|
|
166
|
+
/**
|
|
167
|
+
* ドキュメントを作成または上書き
|
|
168
|
+
* @param data ドキュメントデータ
|
|
169
|
+
* @param options オプション(mergeは現在サポートされていません)
|
|
170
|
+
* @returns WriteResultインスタンス
|
|
171
|
+
*/
|
|
172
|
+
set(data: Record<string, any>, options?: {
|
|
173
|
+
merge?: boolean;
|
|
174
|
+
}): Promise<WriteResult>;
|
|
175
|
+
/**
|
|
176
|
+
* ドキュメントを更新
|
|
177
|
+
* @param data 更新データ
|
|
178
|
+
* @returns WriteResultインスタンス
|
|
179
|
+
*/
|
|
180
|
+
update(data: Record<string, any>): Promise<WriteResult>;
|
|
181
|
+
/**
|
|
182
|
+
* ドキュメントを削除
|
|
183
|
+
* @returns WriteResultインスタンス
|
|
184
|
+
*/
|
|
185
|
+
delete(): Promise<WriteResult>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* クエリクラス
|
|
189
|
+
*/
|
|
190
|
+
export declare class Query {
|
|
191
|
+
private client;
|
|
192
|
+
private collectionPath;
|
|
193
|
+
_queryConstraints: {
|
|
194
|
+
where: Array<{
|
|
195
|
+
field: string;
|
|
196
|
+
op: string;
|
|
197
|
+
value: any;
|
|
198
|
+
}>;
|
|
199
|
+
orderBy?: string;
|
|
200
|
+
orderDirection?: string;
|
|
201
|
+
limit?: number;
|
|
202
|
+
offset?: number;
|
|
203
|
+
};
|
|
204
|
+
constructor(client: FirestoreClient, collectionPath: string, constraints: {
|
|
205
|
+
where: Array<{
|
|
206
|
+
field: string;
|
|
207
|
+
op: string;
|
|
208
|
+
value: any;
|
|
209
|
+
}>;
|
|
210
|
+
orderBy?: string;
|
|
211
|
+
orderDirection?: string;
|
|
212
|
+
limit?: number;
|
|
213
|
+
offset?: number;
|
|
214
|
+
});
|
|
215
|
+
/**
|
|
216
|
+
* フィルター条件を追加
|
|
217
|
+
* @param fieldPath フィールドパス
|
|
218
|
+
* @param opStr 演算子
|
|
219
|
+
* @param value 値
|
|
220
|
+
* @returns Queryインスタンス
|
|
221
|
+
*/
|
|
222
|
+
where(fieldPath: string, opStr: string, value: any): Query;
|
|
223
|
+
/**
|
|
224
|
+
* 並べ替え条件を追加
|
|
225
|
+
* @param fieldPath フィールドパス
|
|
226
|
+
* @param directionStr 並べ替え方向('asc'または'desc')
|
|
227
|
+
* @returns Queryインスタンス
|
|
228
|
+
*/
|
|
229
|
+
orderBy(fieldPath: string, directionStr?: "asc" | "desc"): Query;
|
|
230
|
+
/**
|
|
231
|
+
* 取得件数の制限を設定
|
|
232
|
+
* @param limit 最大件数
|
|
233
|
+
* @returns Queryインスタンス
|
|
234
|
+
*/
|
|
235
|
+
limit(limit: number): Query;
|
|
236
|
+
/**
|
|
237
|
+
* スキップ件数を設定
|
|
238
|
+
* @param offset スキップ件数
|
|
239
|
+
* @returns Queryインスタンス
|
|
240
|
+
*/
|
|
241
|
+
offset(offset: number): Query;
|
|
242
|
+
/**
|
|
243
|
+
* クエリを実行
|
|
244
|
+
* @returns QuerySnapshotインスタンス
|
|
245
|
+
*/
|
|
246
|
+
get(): Promise<QuerySnapshot>;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* クエリ結果クラス
|
|
250
|
+
*/
|
|
251
|
+
export declare class QuerySnapshot {
|
|
252
|
+
private _docs;
|
|
253
|
+
constructor(results: Array<Record<string, any>>);
|
|
254
|
+
/**
|
|
255
|
+
* 結果のドキュメント配列
|
|
256
|
+
*/
|
|
257
|
+
get docs(): DocumentSnapshot[];
|
|
258
|
+
/**
|
|
259
|
+
* 結果が空かどうか
|
|
260
|
+
*/
|
|
261
|
+
get empty(): boolean;
|
|
262
|
+
/**
|
|
263
|
+
* 結果の件数
|
|
264
|
+
*/
|
|
265
|
+
get size(): number;
|
|
266
|
+
/**
|
|
267
|
+
* 各ドキュメントに対してコールバックを実行
|
|
268
|
+
* @param callback 各ドキュメントに対して実行するコールバック関数
|
|
269
|
+
*/
|
|
270
|
+
forEach(callback: (result: DocumentSnapshot) => void): void;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* ドキュメントスナップショットクラス
|
|
274
|
+
*/
|
|
275
|
+
export declare class DocumentSnapshot {
|
|
276
|
+
private _id;
|
|
277
|
+
private _data;
|
|
278
|
+
constructor(id: string, data: Record<string, any> | null);
|
|
279
|
+
/**
|
|
280
|
+
* ドキュメントID
|
|
281
|
+
*/
|
|
282
|
+
get id(): string;
|
|
283
|
+
/**
|
|
284
|
+
* ドキュメントが存在するかどうか
|
|
285
|
+
*/
|
|
286
|
+
get exists(): boolean;
|
|
287
|
+
/**
|
|
288
|
+
* ドキュメントデータを取得
|
|
289
|
+
* @returns ドキュメントデータ(存在しない場合はundefined)
|
|
290
|
+
*/
|
|
291
|
+
data(): Record<string, any> | undefined;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* 書き込み結果クラス
|
|
295
|
+
*/
|
|
296
|
+
export declare class WriteResult {
|
|
297
|
+
/**
|
|
298
|
+
* 書き込み時刻
|
|
299
|
+
*/
|
|
300
|
+
readonly writeTime: Date;
|
|
301
|
+
constructor();
|
|
302
|
+
}
|
|
63
303
|
/**
|
|
64
304
|
* 新しいFirestoreクライアントインスタンスを作成
|
|
65
305
|
* @param config Firestore設定オブジェクト
|