node中mongoose存储数组类型数据
建立模型
数组数据格式:
swiperData : [{imgUrl: String}]
(这种格式写,MongoDB中数组里的每一个对象都会自动生成_id)
例子:
或
swiperData : []
(这种格式写,MongoDB中数组里的每一个对象都只保存传过来的数组中的每一个对象,即一致性)
例子:
// 楼盘信息表
var floorInfosSchema = new mongoose.Schema(
// 楼盘介绍
introduce : String,
// 楼盘轮播图
// [ { "imgUrl": "http://www.zyloushi.com/userfiles/image/20190331/31124722f235c77bac6441_340_242.jpg"}, { "imgUrl": "https://pic6.ajkimg.com/loupan/3517cd768618452dee6408ac806c61b1?imageMogr2/format/jpg/thumbnail/403x274"}]
swiperData : [{imgUrl: String}],
// 楼盘图片
floorImg :String ,
});
var FloorInfos = mongoose.model("floorInfos", floorInfosSchema);
postman传递 数组 参数
MongoDB中显示: