Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Enums mongoose动态定义枚举值_Enums_Mongoose_Schema - Fatal编程技术网

Enums mongoose动态定义枚举值

Enums mongoose动态定义枚举值,enums,mongoose,schema,Enums,Mongoose,Schema,有没有办法动态定义枚举值 var mongoose = require('./index'), TempSchema = new mongoose.Schema({ color: {type: String, enum: ['Red', 'Green', 'Blue']} }); 在上述3种情况下,字符串在设计时定义。 我想要的是从另一个模式文档中提取颜色,并将它们添加到这个枚举数组中。 有可能吗?你可以看这篇文章

有没有办法动态定义枚举值

var mongoose = require('./index'),
TempSchema = new mongoose.Schema({
 color: {type: String, enum: ['Red', 'Green', 'Blue']}
});
在上述3种情况下,字符串在设计时定义。 我想要的是从另一个模式文档中提取颜色,并将它们添加到这个枚举数组中。 有可能吗?

你可以看这篇文章