如何在sails mongo中将json对象添加为属性类型
Document.js如何在sails mongo中将json对象添加为属性类型,json,mongodb,sails.js,models,waterline,Json,Mongodb,Sails.js,Models,Waterline,Document.js module.exports = { attributes: { type: { type: 'string' }, createdBy: { model: 'User', required: true }, body: { type: 'string' }, comments: { model: 'Comments' }
module.exports = {
attributes: {
type: {
type: 'string'
},
createdBy: {
model: 'User',
required: true
},
body: {
type: 'string'
},
comments: {
model: 'Comments'
},
metaInfo: {
type: 'json'
}
}
})
我想知道是否有任何方法可以编写一个类似上面给出的模型,这样,我就可以将一个json对象添加到包含名称-值对的metaInfo
例如:
json:
{name:'Project',value:'MyFirstProject'}
这可能通过水线吗
提前谢谢。我相信这条评论回答了你的问题。如果您需要任何进一步的帮助,您可以参考Sails Github页面中提出的此问题的答案:是的,您可以!正是你上面写的方式。此类型允许您存储JSON对象以及ArrayShanks以获取帮助!