Skip to content

Commit f0f3fc5

Browse files
committed
feat(database): support ServerValue
1 parent 355e4d3 commit f0f3fc5

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

packages/firebase-database/index.android.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,28 @@ export class Query implements IQuery {
337337
}
338338
}
339339

340+
export class ServerValue {
341+
#native: any;
342+
static timeStamp() {
343+
const value = new ServerValue();
344+
value.#native = com.google.firebase.database.ServerValue.TIMESTAMP;
345+
return value;
346+
}
347+
static increment(count: number) {
348+
const value = new ServerValue();
349+
value.#native = com.google.firebase.database.ServerValue.increment(count);
350+
return value;
351+
}
352+
353+
get native() {
354+
return this.#native;
355+
}
356+
357+
get android() {
358+
return this.native;
359+
}
360+
}
361+
340362
export class Reference extends Query implements IReference {
341363
#native: com.google.firebase.database.DatabaseReference;
342364
static fromNative(ref: com.google.firebase.database.DatabaseReference) {

packages/firebase-database/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ declare class Query implements IQuery {
5151
startAt(value: string | number | boolean, key?: string): Query;
5252
}
5353

54+
declare class ServerValue {
55+
readonly native: any;
56+
readonly android: any;
57+
readonly ios: any;
58+
59+
static timeStamp(): ServerValue;
60+
static increment(count: number): ServerValue;
61+
}
62+
5463
declare class Reference extends Query implements IReference {
5564
readonly native: any;
5665
readonly android: any;

packages/firebase-database/index.ios.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,28 @@ export class Query implements IQuery {
271271
}
272272
}
273273

274+
export class ServerValue {
275+
#native: any;
276+
static timeStamp() {
277+
const value = new ServerValue();
278+
value.#native = FIRServerValue.timestamp();
279+
return value;
280+
}
281+
static increment(count: number) {
282+
const value = new ServerValue();
283+
value.#native = FIRServerValue.increment(count);
284+
return value;
285+
}
286+
287+
get native() {
288+
return this.#native;
289+
}
290+
291+
get ios() {
292+
return this.native;
293+
}
294+
}
295+
274296
export class Reference extends Query implements IReference {
275297
#native: FIRDatabaseReference;
276298

0 commit comments

Comments
 (0)