我想知道我如何定义一个bigint类型在一个水系模型使用帆-mysql?找不到任何关于它的适当文件。似乎它不支持bigint类型,但我真的需要它。试图挖掘源代码,我发现了一些东西:https://github.com/balderdashy/sails-mysql/blob/987f4674785970951bc52becdfdb479864106da1/helpers/private/schema/build-schema.js#L29,但它仍然不起作用。
module.exports = {
attributes: {
userId: {
type: 'bigint',
autoIncrement: true,
primaryKey: true,
unique: true,
},
}
};这个仍然在数据库中创建一个整数字段。
发布于 2017-04-07 21:36:59
好的,在深入研究源代码之后,我想我必须为这个字段设置一个名为size的额外属性。将其设置为64将导致水平线创建一个BIGINT字段。
module.exports = {
attributes: {
userId: {
type: 'integer',
size: 64, // waterline will translate this as bigint
autoIncrement: true,
primaryKey: true,
unique: true,
},
}
};发布于 2018-11-07 05:15:25
另一种方法是使用以下属性:
{
type: 'string',
columnType: 'bigint'
}这将忽略Waterline数据类型,并直接强制Postgres/MySQL列数据类型。
发布于 2019-05-14 10:59:49
编辑:我还没有对此进行彻底的测试。毕竟,这是行不通的。
Sails v1.0+中的模型属性不允许使用属性v1.0+,但这似乎有效。我从createdAt属性在水系图书馆中的定义中提取出来(在本文撰写时,第485行)。
module.exports = {
attributes: {
timeOfDay: {
type: 'number',
autoMigrations: { columnType: '_numbertimestamp' }
}
}
};https://stackoverflow.com/questions/43287327
复制相似问题