foxx模型中的属性选项

时间:2014-07-21 11:31:43

标签: arangodb nosql

有没有办法指定Foxx.Model的可接受值?

类似的东西是理想的:

var ExampleModel = Foxx.Model.Extend({}, 
{
    attributes: {
        field: { type: "string", required: true, values: ['one', 'two'] }
    }
});

提前致谢。

1 个答案:

答案 0 :(得分:5)

自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