Skip to content

Instantly share code, notes, and snippets.

@jketcham
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jketcham/e8b4c88c130a2d4b2aae to your computer and use it in GitHub Desktop.
Save jketcham/e8b4c88c130a2d4b2aae to your computer and use it in GitHub Desktop.
Mongoose Schema
var GameSchema = new Schema({
title: String,
description: String,
location: String,
created_on: { type: Date, default: Date.now },
active: { type: Boolean, default: true },
accepting_players: { type: Boolean, default: true },
players: [{
type: Schema.Types.ObjectId,
ref: 'User'
}],
admins: [{
type: Schema.Types.ObjectId,
ref: 'User'
}]
});
// Trying to populate admins
exports.getAdmins = function(req, res) {
Game.findById(req.params.id)
.populate('admins')
.exec(function(err, game) {
return res.json(200, game.admins);
});
};
@jketcham
Copy link
Author

^ Schema and the getAdmins function aren't in the same file FYI, just shown here for simplicity

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