我希望我的模型字段将按原样存储在mysql中。我的用户模型是这样的:
module.exports = {
attributes: {
local: {
email: 'string',
password: 'string'
},
facebook: {
id: 'string',
token: 'string',
email: 'string',
name: 'string'
},
google: {
id: 'string',
token: 'string',
email: 'string',
name: 'string'
}
}
};但这不会在用户模型中创建任何字段。在mysql中存储这些字段应该怎么做?
发布于 2016-08-16 03:24:35
您需要将它们保存为JSON对象。Sails会将你的对象串起来,并将结果保存到你的数据库中。它还会负责解析,所以你不必担心这个问题。尽管如此,它仍然不允许指定对象的内部属性,但我认为没有解决方案。
module.exports = {
attributes: {
local: {
type: 'json'
},
facebook: {
type: 'json'
},
google: {
type: 'json'
}
}
};https://stackoverflow.com/questions/38930099
复制相似问题