-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetupMethod.js
42 lines (38 loc) · 885 Bytes
/
setupMethod.js
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
module.exports = async function setupMethod(client) {
// create mock posts
const testPosts = [
{
_id: 1,
Title: "Test Post 01",
Author: "Test Author 01",
Text: "Test Text 01",
Likes: 1,
NumReplies: 0
},
{
_id: 2,
Title: "Test Post 02",
Author: "Test Author 02",
Text: "Test Text 02",
Likes: 2,
NumReplies: 0
}
];
// create mock users
const testUsers = [
{
_id: 101,
email: "[email protected]",
password: "password"
},
{
_id: 102,
email: "[email protected]",
password: "password"
}
];
await client.connect();
await client.db("users").collection("posts").insertMany(testPosts);
await client.db("users").collection("users").insertMany(testUsers);
await client.close();
}