Hello, good afternoon! I need to develop a simple system, but I have doubts. I'm developing with nodeJs. It is a system for shared racing, where a driver, a passenger is registered. And from the driver and passenger, you can then create a race.
I'm definitely in the assembly of the mongoose schema, I'll post some code to illustrate.
Driver Schema:
var mongoose = require('mongoose')
var Schema = mongoose.Schema;
var motoristaSchema = new Schema({
nm_Motorista: {type: String, require: true},
dt_Nasc: {type: String, require: true},//ano, mes, dia
cd_Cpf: {type: Number, require: true},
ds_ModeloCarro: {type: String, require: true},
ic_Status: {type: String, enum: ['ATIVO', 'INATIVO']},
sg_Sexo: {type: String}
})
var Motorista = mongoose.model("Motorista", motoristaSchema)
module.exports = Motorista
Passenger Schema:
var mongoose = require('mongoose')
var Schema = mongoose.Schema;
var passageiroSchema = new Schema({
nm_Passageiro: {type: String, require: true},
dt_Nasc: {type: String, require: true},//ano, mes, dia
cd_Cpf: {type: Number, require: true},
sg_Sexo: {type: String}
})
var Passageiro = mongoose.model("Passageiro", passageiroSchema)
module.exports = Passageiro
Race Schema (Containing error):
var mongoose = require('mongoose')
var Schema = mongoose.Schema;
var Motorista = require('./motorista')
var Passageiro = require('./passageiro')
var corridaSchema = new Schema({
ds_Motorista: motoristaSchema,
ds_Passageiro: passageiroSchema,//ano, mes, dia
vl_Corrida: {type: Number, require: true}
})
var Corrida = mongoose.model("Corrida", corridaSchema)
module.exports = Corrida
Passenger and driver registration is ok, I need to create a racing schema where I then pass a driver and a passenger to persist in the bank.
Thank you in advance. Thanks.