Skip to content

Commit e121c60

Browse files
ServerValues compat (#4728)
1 parent 8494098 commit e121c60

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/database/src/api/Database.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
goOffline
2828
} from '../exp/Database';
2929
import { ref, refFromURL } from '../exp/Reference_impl';
30+
import { increment, serverTimestamp } from '../exp/ServerValue';
3031

3132
import { Reference } from './Reference';
3233

@@ -35,16 +36,8 @@ import { Reference } from './Reference';
3536
*/
3637
export class Database implements FirebaseService, Compat<ExpDatabase> {
3738
static readonly ServerValue = {
38-
TIMESTAMP: {
39-
'.sv': 'timestamp'
40-
},
41-
increment: (delta: number) => {
42-
return {
43-
'.sv': {
44-
'increment': delta
45-
}
46-
};
47-
}
39+
TIMESTAMP: serverTimestamp(),
40+
increment: (delta: number) => increment(delta)
4841
};
4942

5043
/**

packages/database/src/exp/ServerValue.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@
1515
* limitations under the License.
1616
*/
1717

18+
const SERVER_TIMESTAMP = {
19+
'.sv': 'timestamp'
20+
};
21+
1822
export function serverTimestamp(): object {
19-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20-
return {} as any;
23+
return SERVER_TIMESTAMP;
2124
}
2225

2326
export function increment(delta: number): object {
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
return {} as any;
27+
return {
28+
'.sv': {
29+
'increment': delta
30+
}
31+
};
2632
}

0 commit comments

Comments
 (0)