forked from twang1905/CS-546-Final-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearData.js
59 lines (52 loc) · 1.32 KB
/
clearData.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import {
users,
buildings,
rooms,
containers,
items,
itemImages
} from "./config/mongoCollections.js";
import { closeConnection } from "./config/mongoConnection.js";
let usersCollection = await users();
let buildingsCollection = await buildings();
let roomsCollection = await rooms();
let containersCollection = await containers();
let itemsCollection = await items();
let itemImagesCollection = await itemImages();
try {
await usersCollection.drop();
console.log("Users collection dropped.");
} catch (e) {
console.log("No users collection found.");
}
try {
await buildingsCollection.drop();
console.log("Buildings collection dropped.");
} catch (e) {
console.log("No buildings collection found.");
}
try {
await roomsCollection.drop();
console.log("Rooms collection dropped.");
} catch (e) {
console.log("No rooms collection found.");
}
try {
await containersCollection.drop();
console.log("Containers collection dropped.");
} catch (e) {
console.log("No containers collection found.");
}
try {
await itemsCollection.drop();
console.log("Items collection dropped.");
} catch (e) {
console.log("No items collection found.");
}
try {
await itemImagesCollection.drop();
console.log("Item images collection dropped.");
} catch (e) {
console.log("No item images collection found.");
}
closeConnection();