Skip to content

Instantly share code, notes, and snippets.

@DouglasHennrich
Last active August 29, 2015 14:13
Show Gist options
  • Save DouglasHennrich/94273d97d53f12f32a5d to your computer and use it in GitHub Desktop.
Save DouglasHennrich/94273d97d53f12f32a5d to your computer and use it in GitHub Desktop.
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 );
});
};
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