架构
var CarSchema = new Schema({
make: String,
model: String,
listPrice: String,
price: Number,
year: Number,
VIN : String ,
kilometers: Number,
transmission: String,
engine: String,
driveline: String,
doors: Number,
fueltype: String,
exteriorcolor: String,
interiorcolor: String,
bodystyle: String,
details: String,
images: Schema.Types.Mixed,
ac: Boolean,
climateControl: Boolean,
electricwindows: Boolean,
powerLocks: Boolean,
powerSeats: Boolean,
sunroof: Boolean,
CDplayer: Boolean,
CDchanger: Boolean,
cruiseControl: Boolean,
heatedSeats: Boolean,
navigation: Boolean,
leatherSeats: Boolean,
clothSeats: Boolean,
ABS: Boolean,
tintedWindows: Boolean,
xenonHeadlights: Boolean,
fullyLoaded: Boolean,
sold: Boolean
});
module.exports = mongoose.model('Car', CarSchema);
router.get('/:_id', function(req, res, next) {
Car.findById(req.params._id, function (err, cars) {
if (err) {
res.send(err);
}
res.render("cars", { cars: cars });
});
});
现在,如果我尝试使用汽车,即使我通过外壳检查数据库时,它们的布尔值字段都设置为true,但它们并非全部为假。
如果我在另一页上执行“ cars.find”,则此处仅当我通过id带入对象时才带正确的值。