-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
42 lines (34 loc) · 1.17 KB
/
seed.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
const express = require("express"),
mongoose = require("mongoose"),
comment = require("./models/commentmodel"),
campbookpost = require("./models/campbookpostmodel"),
User = require("./models/usermgt"),
camppostRoutes = require("./routes/camppost"),
commentRoutes = require("./routes/comments"),
userRoutes = require("./routes/user"),
formidable = require("formidable"),
path = require("path"),
cloudinary = require ("cloudinary").v2;
function seedStartFresh(){
campbookpost.remove({}, (err)=>{
if(!err){
console.log("All Posts Deleted")
}
})
User.remove({}, (err)=>{
if(!err){
console.log("All Users Deleted")
}
})
comment.remove({}, (err)=>{
if(!err){
console.log("All Comments Deleted")
}
})
cloudinary.api.delete_all_resources({resource_type: 'image'}, (err)=>{
if(!err){
console.log("All Images Deleted")
}
});
}
module.exports = seedStartFresh;