Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @package [db] - Application db connection & schema loading
- * @author [anikett] smartData Inc
- */
- 'use strict';
- /* DB */
- var mongoose = require('mongoose');
- mongoose.Promise = Promise;
- require('../api/models/Component');
- require('../api/models/User');
- require('../api/models/Category');
- /* database uri */
- var uri = 'mongodb://' + process.env.DB_HOST + ':' + process.env.DB_PORT + '/' + process.env.DB_NAME;
- var options = {
- user: process.env.DB_USERNAME,
- pass: process.env.DB_PASSWORD,
- server: {
- socketOptions: {
- keepAlive: 1,
- connectTimeoutMS: 30000
- }
- },
- replset: {
- socketOptions: {
- keepAlive: 1,
- connectTimeoutMS: 30000
- }
- }
- }
- mongoose.connect(uri, options);
- var db = mongoose.connection;
- db.on('error', console.error.bind(console, 'connection error:'));
- db.once('open', function(callback) {
- console.log('Database connection successful!');
- });
- /* end DB */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement