-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.ts
More file actions
executable file
·38 lines (34 loc) · 859 Bytes
/
status.ts
File metadata and controls
executable file
·38 lines (34 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @license
* Copyright FabricElements. All Rights Reserved.
*/
import {FieldValue, getFirestore} from 'firebase-admin/firestore';
interface Data {
id?: string;
status?: string;
description?: string;
name?: string;
[x: string]: any,
}
/**
* Update Status Collection with Errors
* @param {Data} data
* @deprecated Not in use
*/
export const update = async (data: Data): Promise<void> => {
if (!data.id || !data.status) {
throw new Error('Missing input data');
}
const db = getFirestore();
const timestamp = FieldValue.serverTimestamp();
const ref = db.collection('status').doc(data.id);
const status = {
backup: false,
description: data.description || null,
events: FieldValue.increment(1),
name: data.name || null,
status: data.status,
timestamp,
};
await ref.set(status, {merge: true});
};