猫鼬无论如何都会返回我的布尔值

时间:2018-09-21 05:09:51

标签: mongoose boolean

架构

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带入对象时才带正确的值。

0 个答案:

没有答案
相关问题