-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
31 lines (27 loc) · 800 Bytes
/
db.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
var mongoose = require('mongoose'),
nconf = require( 'nconf' );
var Schema = mongoose.Schema;
var thumbSchema = new Schema({
file: String,
});
var imageSchema = new Schema({
file: String,
});
var wordSchema = new Schema({
word: String,
syllable: Number,
type: String,
thumbs: [thumbSchema],
images: [imageSchema],
fetched_date: { type: Date, default: Date.now }
});
mongoose.model('words', wordSchema);
nconf.use('file', { file: __dirname + '/config.json' });
var user = nconf.get('mongo:username');
var pass = nconf.get('mongo:password');
var database = nconf.get('mongo:database');
var host = nconf.get('mongo:hostname');
var dsn = 'mongodb://' + user + ':' + pass + '@' + host + '/' + database;
mongoose.connect(dsn, function(err) {
if (err) throw err;
});