Skip to content

Instantly share code, notes, and snippets.

@swallentin
Created September 20, 2012 06:04
Show Gist options
  • Save swallentin/3754204 to your computer and use it in GitHub Desktop.
Save swallentin/3754204 to your computer and use it in GitHub Desktop.
Mongoose.js Model Schema Definition Template
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
, UserSchema = require('./User').Schema
, GameSchema = new Schema({
'name': { type: String },
'player_a': { type: ObjectId, ref: "User" },
'player_b': { type: ObjectId, ref: "User" },
'score': { type: Number, default: 0}
});
exports.Schema = GameSchema;
exports.Model = mongoose.model('Game', GameSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment