const mongoose = require('mongoose');
const { Schema } = mongoose;
const NoteSchema = new Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'user',
},
title: {
type: String,
required: true,
},
description: {
type: File, //for attachment of file (Error occurred here)
required: true,
},
tag: {
type: String,
default: 'General',
},
date: {
type: Date,
default: Date.now,
},
});
module.exports = mongoose.model('notes', NoteSchema);
1条答案
按热度按时间yjghlzjz1#
正如我们可以在官方文档mongoose中读到的关于
SchemaTypes
的Mongoose版本6.6.4而不是File
,我在SchemaTypes(docs)中找不到它。你应该使用Buffer
或String
,就像你上面提到的那样。当它涉及到文件和你上面的例子时,我也会使用source
而不是description
。