Last active
August 29, 2015 14:22
-
-
Save jeftarmascarenhas/c49297ccf44effc98a7d to your computer and use it in GitHub Desktop.
Modeling Users Mongoose
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
/* | |
Objetivo: cadastrar usuários do sistema, são três tipos de cadastro: vendedor, cliente, admin | |
Preciso que você veja se esse Schema está bom, ruim ou uma merda e dizer apenas em que espctos precisa | |
melhorar. | |
*/ | |
var UserSchema = new Schema({ | |
name:{type: String, required:true}, | |
email:{type: String, required:true, | |
index:{ | |
unique: true | |
} | |
}, | |
types:{type: String, default:['vendedor, cliente, admin'], required:true }, | |
documents:{ | |
cpf:{type: Number, min:0}, | |
cnpj:{type: Number, min:0}, | |
rg:{type: Number, min:0} | |
}, | |
active:{type: String, default:['ativo', 'inativo']}, | |
address:{ | |
cep:{type: Number, required:true}, | |
city:{type: String, default:''}, | |
street:{type: String, default:''}, | |
city:{type: String, default:''}, | |
district:{type: String, default:''}, | |
number:{type: Number, min:0}, | |
complement:{type: String, default:''} | |
}, | |
contact:{ | |
phone:{type: Number, min:0}, | |
telephone:{type: Number, min:0}, | |
operator:{type: String, default:''} | |
}, | |
financial:{ | |
bank:{type:String, default:''}, | |
agency:{type:Number, min:0}, | |
account:{type:Number, min:0}, | |
discount:{type:String, default:''}, | |
commission:{type:Number}, | |
credit :{type:Number }, | |
limit :{type:Number }, | |
}, | |
password:{type:String, default:''} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ta ok!