Created
February 1, 2015 15:50
-
-
Save DouglasHennrich/84673a8804fce2315d46 to your computer and use it in GitHub Desktop.
Quero adicionar os dois IDs( req.body.meuId e req.body.outroId ) dentro do array matchs dentro do field "campo"
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
update_match = function(req,res){ | |
var query = { _id : req.params.id } | |
, mod = { $pushAll : { 'matchs.campo' : [mongoose.Types.ObjectId( req.body.meuId ), | |
mongoose.Types.ObjectId( req.body.outroId )] } } | |
; | |
Model.update( query, mod, function(err,data){ | |
if (err){ console.log( err ); return res.json(err); } | |
console.log( 'Sucesso: ' + data ); | |
res.json( data ); | |
}) | |
}; |
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
{ | |
"_id": ObjectId("54ce4a92dba7d25e10a30cd0"), | |
"users": [ | |
ObjectId("54cd3f34a5e4e1c4d181fcd5"), | |
ObjectId("54ce4aa1dba7d25e10a30cd1") | |
], | |
"matchs": [ ], | |
"name": "Nome do Evento", | |
"idFace": "456875432", | |
"__v": 0 | |
} |
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
(function(){ | |
'use_strick' | |
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var EventoSchema = new Schema({ | |
idFace : { type : String, default : '' } | |
, name : { type : String, default : '' } | |
, matchs : [{ type : Schema.Types.ObjectId, ref : 'User' }] | |
, users : [{ type : Schema.Types.ObjectId, ref: 'User' }] | |
}); | |
module.exports = mongoose.model( 'Evento', EventoSchema ); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment