如何将json对象添加为sails-mongo中的属性类型

Div*_*non 5 json models mongodb sails.js waterline

文档.js

module.exports = {

  attributes: {

    type: {
        type: 'string'
    },
    createdBy: {
        model: 'User',
        required: true
    },
    body: {
        type: 'string'
    },
    comments: {
        model: 'Comments'
    },
    metaInfo: {
        type: 'json'
    }

 }
Run Code Online (Sandbox Code Playgroud)

};

我想知道是否有任何方法可以编写像上面给出的模型那样的模型,这样我就可以向包含名称-值对的metaInfo添加一个 json 对象。

例如:json: { name: 'Project', value: 'MyFirstProject'}

这可以通过水线吗?

提前致谢。

Yed*_*nan 5

我相信评论回答了你的问题。如果您需要任何进一步的帮助,您可以参考 Sails Github 页面中提出的这个问题的答案:JSON Array of Strings