【发布时间】:2021-08-17 02:08:51
【问题描述】:
我想将我的字符串数组传递给我的架构。正如您在 auth.js image:image 中看到的那样,我将图像数组传递给我的 mongodb 属性图像,并且我在 image 中成功获取了字符串数组,但我尝试了$push, $each 之类的一切,但我不知道如何将图像数组传递给我的 Mongodb 模式。希望您能理解我的问题。
Schema.js
const mongoose=require('mongoose');
const mySchema=mongoose.Schema({
image:{
type:[String],
required:true,
value:[String]
}
})
const MyCattle=mongoose.model('cattle_list',mySchema);
auth.js
const finaldata = new MyCattle({
image:[image]
})
module.exports=MyCattle;
【问题讨论】:
-
这能回答你的问题吗? Store images in a MongoDB database
-
我不想存储图像。我想传递包含图像名称的字符串数组。