1
I have the following collection:
// SUSPEITOS - INICIO //
const suspeitosSchema = new mongoose.Schema({
nome: { type: String },
sexo: { type: String },
corPele: { type: String },
altura: { type: String },
peso: { type: String },
tamanhoCabelo: { type: String },
corCabelo: { type: String }
})
// ACOES //
const acoesSchema = new mongoose.Schema({
dataCadastro: { type: Date, default: Date.now },
fonte: { type: String },
bo: { type: String },
numeroBo: { type: Number },
imagem: { type: String },
relato: { type: String },
modus: { type: String },
falhasApuradas: { type: String },
dataOcorrencia: { type: Date },
latitude: { type: String },
longitude: { type: String },
suspeitos: [suspeitosSchema]
})
I need to register a json that I receive from a form via POST, registering is, however, I am using a multi-select (http://isteven.github.io/angular-multi-select/#/main) and its return is another json, as you can see below:
When sending the form through the POST, register, but the data that came from JSON Multiselect register as follows, notice the items "source" and "suspects":
{
"_id" : ObjectId("5a04a17af7a3373fe007cbca"),
"fonte" : "[object Object],[object Object],[object Object]",
"eventosDeRisco" : [
],
"acoesCriminosas" : [
],
"alertas" : [
],
"veiculos" : [
],
"suspeitos" : [
{
"nome" : "[object Object],[object Object]",
"_id" : ObjectId("5a04a17af7a3373fe007cbcb")
}
],
"dataCadastro" : ISODate("2017-11-09T18:42:02.842+0000"),
"__v" : NumberInt(0)
}
You’ll need to do the same thing you did to suspects at source and I noticed you’re coming
name
instead ofnome
that was modeled.– BrTkCa
name is a multiselect property, I can’t change it. I can’t understand the right way to get this JSON to register correctly.
– Fred