Mongoose Data Types 如何定义多个类型值? ESLint 错误

Mongoose Data Types how to define multiple type values ? ESLint error

我想将一个字段 'lines' 定义为一个值数组,它可以是不同类型(数字或字符串或布尔值或日期)

当我尝试时:

lines: [
{
  type: String,
  content: Mixed
}

]

我收到 ESLint 错误消息:未定义混合

我应该写吗?

 const Schema = mongoose.Schema;
 ...
 lines: [
   Schema.Types.Mixed
 ]

根据 mongoose documentation 你可以使用如下的混合模式类型

var schema = new Schema({
ofMixed:    [Schema.Types.Mixed],
})

// example use

var Thing = mongoose.model('Thing', schema);

m.ofMixed = [1, [], 'three', { four: 5 }];
m.save(callback);