generated from COPS-IITBHU/ubiquitous_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearDb.js
78 lines (70 loc) · 1.35 KB
/
clearDb.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const mongoose = require("mongoose");
const DB = process.env.DATABASE;
const paModel = require("./models/pa_m");
const userModel = require("./models/User_m");
const instiModel = require("./models/ins_m");
const caModel = require("./models/ca_m");
const cartModel = require("./models/cart_m");
const deleteAllUsers = async () => {
await userModel.remove(
{},
{
justOne: false,
}
);
};
const deleteAllCa = async () => {
await caModel.remove(
{},
{
justOne: false,
}
);
};
const deleteAllPa = async () => {
await paModel.remove(
{},
{
justOne: false,
}
);
};
const deleteAllCarts = async () => {
await cartModel.remove(
{},
{
justOne: false,
}
);
};
const deleteAllInsti = async () => {
await instiModel.remove(
{},
{
justOne: false,
}
);
};
async function fun(){
console.log('in fun');
const x = await caModel.findById("61e096b62e433f40052c4744");
console.log(x);
}
mongoose
.connect(DB, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Successfully connected to database");
// fun();
deleteAllUsers();
deleteAllCa();
deleteAllPa();
deleteAllInsti();
deleteAllCarts();
})
.catch((err) => {
console.log("There was some error connecting to the database");
console.log(err);
});