-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.js
27 lines (22 loc) · 907 Bytes
/
reset.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
/******* Don't call this file until you are 100% sure, this will erase everything */
var express = require("express"),
app = express(),
bodyParser = require("body-parser");
var mongoose = require('mongoose');
var fetch = require("node-fetch");
var rimraf = require("rimraf");
let config = require('/cfg/storage_config.json');
/****** mongoose config */
mongoose.connect('mongodb://localhost/storage', { useNewUrlParser: true, useUnifiedTopology: true });
const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
console.log("database connected");
reset_all();
});
function reset_all() {
mongoose.connection.db.dropDatabase(function (err, result) {
if (err) return console.log("database wasn't dropped");
rimraf(config.folder_path, function () {console.log("everything is reset 0");});
});
}