Created
February 20, 2015 20:03
-
-
Save DouglasHennrich/88dd1a73518ed968edfa to your computer and use it in GitHub Desktop.
This file contains hidden or 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 query = { $and : [ | |
{ idFace : { $in : [req.body.idFace] } } | |
, { "users.gender" : 'male' } | |
]} | |
; | |
Model.find( query ) | |
.populate({ | |
path : 'users.user' | |
, match : { gender : 'male' } | |
}) | |
.exec( function( err, data ){ | |
if (err){ console.log( 'Erro: ' + err ); return res.json(err); } | |
console.log( 'Sucesso: ', data ); | |
res.json( data ); | |
}); |
This file contains hidden or 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
(function(){ | |
'use_strict' | |
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var UserSchema = new Schema({ | |
_id : false | |
, user : { type : Schema.Types.ObjectId, ref: 'User' } | |
, gender : { type : String, default : '' } | |
}); | |
var EventoSchema = new Schema({ | |
idFace : { type : String, default : '' } | |
, name : { type : String, default : '' } | |
, matchs : [{ type : Schema.Types.Mixed }] | |
, likes : [{ type : Schema.Types.Mixed }] | |
, users : [UserSchema] | |
}); | |
module.exports = mongoose.model( 'Evento', EventoSchema ); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment