2
I have the following document(Schema):
var CandidatoSchema = new Schema ({
id_login: Schema.Types.ObjectId,
nome: String,
cpf: String,
dataNascimento: Date,
sexo: String,
estadoCivil: String,
endereco: {
endereco: String,
numero: Number,
bairro: String,
complemento: String,
cep: String,
uf: String,
cidade: String
}
});
I have a Form with these fields, when the user clicks the button Salvar
it will send the data to my route cadastro
:
in my registration route have a console.log(req.body)
: which shows the data sent.
{ nome: 'NomeSs',
cpf: 'xxx.xxx.xxx-xx',
endereco:
{ endereco: 'rua alameda',
numero: '111',
bairro: 'bairro',
complemento: 'compras',
cep: '111-111' }
I’m having trouble entering the data into documents embedded
, in this case is not entering the data relating to endereco
.
My role to insert:
exports.Add = function(req, res) {
console.log(req.body);
var person = new Person();
// Tentei usar está linha, mas não funciona...
person.endereco.push(req.body.endereco);
person.save(function(err, person) {
if(err) res.sendStatus(500);
res.sendStatus(201);
});
};
Does anyone have any idea how to insert documents embedded
?
the
push
I really... thank you very much... I work right here...– MeuChapeu