Skip to content

Instantly share code, notes, and snippets.

@VoX
Created October 21, 2014 21:17
Show Gist options
  • Save VoX/435b44017ea137dcaaa4 to your computer and use it in GitHub Desktop.
Save VoX/435b44017ea137dcaaa4 to your computer and use it in GitHub Desktop.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/events');
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback() {
console.log("connected to mongodb");
});
var eventSchema = mongoose.Schema({
name: String,
id: Number,
location_name: String,
start_time: Date,
geo: {
type: [Number],
index: '2d'
}
});
var Event = mongoose.model('Event', eventSchema);
exports.storeEvent = function (event) {
new Event(event).save(function (err) {
if (err) throw err;
})
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment