mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 05:17:05 +08:00
just use the mongoose model
This commit is contained in:
+5
-14
@@ -1,16 +1,7 @@
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const url = process.env.TALK_MONGO_URL;
|
||||
const Setting = require('../models/setting');
|
||||
const defaults = {id: '1', moderation: 'pre'};
|
||||
|
||||
if (!url) {
|
||||
throw new Error('environment variable TALK_MONGO_URL must be defined');
|
||||
}
|
||||
|
||||
MongoClient.connect(url).then(db => {
|
||||
const Setting = db.collection('settings');
|
||||
const defaults = {id: 1, moderation: 'pre'};
|
||||
|
||||
Setting.update({id: 1}, {$setOnInsert: defaults}, {upsert: true}).then(() => {
|
||||
console.log('created settings object.');
|
||||
process.exit();
|
||||
});
|
||||
Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}).then(() => {
|
||||
console.log('created settings object.');
|
||||
process.exit();
|
||||
}).catch(console.error);
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
"imports-loader": "^0.6.5",
|
||||
"json-loader": "^0.5.4",
|
||||
"mocha": "^3.1.2",
|
||||
"mongodb": "^2.2.11",
|
||||
"pre-git": "^3.10.0",
|
||||
"pym.js": "^1.1.1",
|
||||
"react": "15.3.2",
|
||||
|
||||
Reference in New Issue
Block a user