小编Ope*_*nds的帖子

Mongodb 架构/模型中文件的字段类型是什么?

我正在使用 Mongo Schema 来发布表单。适用于所有字符串,但现在我正在尝试上传文件。我应该指定文件在架构中的字段类型是什么?

//create model/schema
const TrackSchema = new Schema({
    title:{
        type: String, 
        required: true
    },
    length:{
        type: String, 
        required: true
    }, 
    available:{
        type: Boolean, 
        required: true
    },
    image:{
        type: String, 
        required: true
    }, 
    date: {
        type: Date, 
        default: Date.now
    }, 
    source: {
        type: **??, 
        required: true
    }
})
Run Code Online (Sandbox Code Playgroud)

我应该将“源”字段设置为什么类型,该字段将是来自表单的文件

mongodb node.js

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

mongodb ×1

node.js ×1