I have a simple Mongoose object:
module.exports = mongoose.model('Flight', new Schema({
name: String,
nkr: Number,
outbound: {
nkr: Number,
weight: Number,
facilities: Array,
}
});
And when I create a new blank flight, I get back data as follows:
"fligts": [{
"_id": "55e8642d4666a2141019a372",
"extra" : {
"facilities": []
}
}]
This is inconvenient as if i run flight.outbound.length
returns 1
. I want a black outbound
object if nothing is entered, is this possible?