Last active
August 29, 2015 14:13
-
-
Save DouglasHennrich/94273d97d53f12f32a5d 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 usuarioJaExiste = function ( err, data, res, req ) { | |
var dados, | |
model; | |
if ( err ) return res.json(err); | |
if ( data ) return res.json({ Error: "Usuario ja existe.", Code: 0 }); | |
dados = { | |
idFace: req.body.idFace, | |
arrayUsuario: [{ | |
name : req.body.name, | |
gender: req.body.gender | |
}] | |
} | |
model = new Model( dados ); | |
model.save( function(err, data){ | |
callback( err, data, res ); | |
}); | |
}; |
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 mongoose = require( 'mongoose' ); | |
var Schema = mongoose.Schema; | |
var UsuarioSchema = new Schema({ | |
arrayUsuario: [{ | |
name : { type: String, default: '' } | |
, age: { type: String, default: '' } | |
, gender: { type: String, default: '' } | |
, idEventos: { type: Array, default: [] } | |
, matchs: { type: Array, default: [] } | |
, fotos: { type: Array, default: [] } | |
}] | |
, idFace: { type: String, required: true, unique: true } | |
, created_at: { type: Date, default: Date.now } | |
}); | |
module.exports = mongoose.model( 'Usuario', UsuarioSchema ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment