These are chat archives for Automattic/mongoose

21st
Apr 2018
Mohammed Boudad
@matrixersp
Apr 21 2018 08:12
Hey guys,
I need your thoughts on this
I'm defining a Mongoose schema (MongoDB) for a carpool platform
here's how it works, drivers post rides and users request rides. Should I put requests and rides separately or use a single schema for both like in this case
const rideSchema = mongoose.Schema({
    _id: mongoose.Schema.Types.ObjectId,
    driver: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
    passengers: [{
        passengerId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
        seatsNumber: { type: Number, default: 1 },
        validated: { type: Boolean, default: false }
    }],
    pickUp: { type: String, required: true },
    dropOff: { type: String, required: true },
    date: { type: String },
    history: { type: Boolean, default: false },
    createdAt: { type: Date, default: Date.now },
    updatedAt: { type: Date, default: Date.now }
});