SHARE
TWEET

Untitled

a guest Aug 12th, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mongoose = require('mongoose');
  2. var database = require('../config/database');
  3. var mongoOptions = { db: { safe: true }};
  4. mongoOptions.user = database.user;
  5. mongoOptions.pass = database.pass;
  6.  
  7. console.log('Running mongoose version %s', mongoose.version);
  8.  
  9. mongoose.connect(database.url, mongoOptions, function (err, res) {
  10.   if (err) {
  11.     console.log ('ERROR connecting to: ' + database.url + '. ' + err);
  12.   } else {
  13.     console.log ('Successfully connected to: ' + database.url);
  14.   }
  15. });
  16.  
  17. var Schema = mongoose.Schema;
  18. var citySchema = new Schema({
  19.     name: String,
  20.     url: String,
  21.     uf: String,
  22.     dtRequest: Date,
  23.     active: Boolean,
  24.     loc: {
  25.         type: [Number],
  26.         index: '2dsphere'
  27.     }
  28. });
  29.  
  30. module.exports = mongoose.model('City', citySchema);
  31.  
  32. var db = mongoose.connection;
  33. db.on('error', console.error);
  34.  
  35. process.on('SIGINT', function() {
  36.   db.close(function () {
  37.     console.log('Mongoose default connection disconnected through app termination');
  38.     process.exit(0);
  39.   });
  40. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top