-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy path02-workspaces.ts
63 lines (58 loc) · 1.78 KB
/
02-workspaces.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* SPDX-FileCopyrightText: 2014-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { Firestore, Timestamp } from "@google-cloud/firestore";
import { WorkspaceInput } from "../models";
import { testUsers as users } from "./01-users";
/**
* Test workspaces.
*/
export const testWorkspaces: (WorkspaceInput & { id: string })[] = [
{
id: "DwYchGFGpk",
ownerId: users[0].localId!,
name: "Personal workspace",
created: Timestamp.fromDate(new Date(+users[0].createdAt!)),
updated: Timestamp.fromDate(new Date(+users[0].createdAt!)),
archived: null,
},
{
id: "YfYKTcO9q9",
ownerId: users[1].localId!,
name: "Personal workspace",
created: Timestamp.fromDate(new Date(+users[1].createdAt!)),
updated: Timestamp.fromDate(new Date(+users[1].createdAt!)),
archived: null,
},
{
id: "c2OsmUvFMY",
ownerId: users[2].localId!,
name: "Personal workspace",
created: Timestamp.fromDate(new Date(+users[2].createdAt!)),
updated: Timestamp.fromDate(new Date(+users[2].createdAt!)),
archived: null,
},
{
id: "uTqcGw4qn7",
ownerId: users[3].localId!,
name: "Personal workspace",
created: Timestamp.fromDate(new Date(+users[3].createdAt!)),
updated: Timestamp.fromDate(new Date(+users[3].createdAt!)),
archived: null,
},
{
id: "vBHHgg5ydn",
ownerId: users[4].localId!,
name: "Personal workspace",
created: Timestamp.fromDate(new Date(+users[4].createdAt!)),
updated: Timestamp.fromDate(new Date(+users[4].createdAt!)),
archived: null,
},
];
export async function seed(db: Firestore) {
const batch = db.batch();
for (const { id, ...workspace } of testWorkspaces) {
const ref = db.doc(`workspace/${id}`);
batch.set(ref, workspace, { merge: true });
}
await batch.commit();
}