Skip to content

Instantly share code, notes, and snippets.

@warseph
Last active December 10, 2015 08:38
Show Gist options
  • Select an option

  • Save warseph/4409089 to your computer and use it in GitHub Desktop.

Select an option

Save warseph/4409089 to your computer and use it in GitHub Desktop.
Mongoose example
// models.js
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
model = mongoose.model;
var userSchema = new Schema({
name: String,
email: ObjectId,
password: String
});
exports.User = mongoose.model('User', userSchema);
// test.js
var models = require('./models');
var user = new models.User({name: 'Test User', email: 'test@test.test', pass: 'pass'});
@Mephasto
Copy link

var Schema = mongoose.Schema
  , ObjectId = Schema.ObjectId;

var Fan = new Schema({
    title    : ObjectId
  , place     : String
  , date      : Date
  , body      : String
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment