有没有办法指定 Foxx.Model 的接受值?
类似的东西是理想的:
var ExampleModel = Foxx.Model.Extend({},
{
attributes: {
field: { type: "string", required: true, values: ['one', 'two'] }
}
});
提前致谢。
最佳答案
自 ArangoDB 的最新版本以来,这是可能的。它具有 integration of Joi into Foxx ,因此您现在可以执行以下操作:
var Foxx = require("org/arangodb/foxx");
var joi = require("joi");
var ExampleModle = Foxx.Model.extend({
schema: {
field: joi.string().required().valid(['one', 'two'])
}
});
请参阅documentation of Joi了解更多信息。
关于arangodb - Foxx模型中的属性选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24864041/