Last active
August 29, 2015 14:06
-
-
Save jketcham/e8b4c88c130a2d4b2aae to your computer and use it in GitHub Desktop.
Mongoose Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
^ Schema and the getAdmins function aren't in the same file FYI, just shown here for simplicity