mongodb model 查询,把数组字段替换成 数组的长度
rt
var blogSchema = new Schema({ title: String, author: String, body: String, ** comments: [{ body: String, date: Date }], //我想把这个数组 替换成 count:10** date: { type: Date, default: Date.now }, hidden: Boolean, meta: { votes: Number, favs: Number } }); BlogSchema.findOne().populate(‘comments’).exec(function (err, blogSchema) {
})