Waterline supports indexing out of the box ,不幸的是不适用于任何适配器。
sails-mysql适配器似乎不支持它。
例如,跟随模型中的字段,将会出错:
user: {
model: 'user',
index: true
}
Error: The attribute
user
on thetopic
model contains invalid properties. The propertyindex
isn't a recognized property.
问题是,如果适配器不支持索引,那么在 SailsJS 中最好的方法是什么?
我正在使用:
{
"sails": "^1.0.0-27",
"sails-mysql": "^1.0.0-7",
"waterline": "v0.13.0-rc4"
}
最佳答案
在对 sails-mysql
、waterline-schema
和 waterline
模块进行逆向工程后,我发现在 中设置索引的可能性未被记录autoMigrations
属性。喜欢以下内容:
foo: {
type: 'number'
autoMigrations: { index: true }
}
关于mysql - 使用 SailsJS 在 MySQL 数据库表中设置索引的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42506071/