8
I own a collection called suspeitosSchema
and another call acoesSchema
.
suspectsSchema:
const suspeitosSchema = new mongoose.Schema({
sexo: { type: String },
etnia: { type: String },
cumprimentoCabelo: { type: String },
corCabelo: { type: String },
altura: { type: String },
peso: { type: String },
tipoArma: { type: String },
armaBranca: { type: String },
armaDeFogo: { type: String },
observacao: { type: String }
})
acoesSchema:
const acoesSchema = new mongoose.Schema({
dataCadastro: { type: Date, default: Date.now },
fonte: { type: Array, required: true },/*
bo: { type: String },*/
numeroBo: { type: Number, required: true },
imagem: { type: String },
relato: { type: String, required: true },
modus: { type: String, required: true },
falhasApuradas: { type: String, required: true },
data: { type: Date, required: true },
latitude: { type: String, default: '-27.226520' },
longitude: { type: String, default: '-52.018375' },
suspeitos: [suspeitosSchema],
veiculos: [veiculosSchema],
tipoAcao: { type: String, required: true, required: true }
})
Note that in the collection acoes has a field called suspeitos
, in this way, I can store from a form the data of a suspect along with the rest of the data.
However, I need to add more than one suspect per form, I’m not able to do this, does anyone have any idea how I could do?
I think iterating the number of suspects and adding to an array before storing in
acoesSchema
ai stores this array ;)– Lauro Moraes