使用SailsJS在MySQL数据库表中设置索引的最佳方法是什么?

时间:2017-02-28 10:22:00

标签: mysql node.js sails.js waterline

Waterline supports indexing out of the box,遗憾的是没有任何适配器。

sails-mysql适配器似乎不支持它。

例如,在模型中跟随字段会出错:

user: { 
  model: 'user',
  index: true
}
  

错误:user模型上的属性topic包含无效的属性。财产index不是公认的财产。

问题是,如果适配器不支持索引,那么在SailsJS中执行此操作的最佳方法是什么?

我正在使用:

{
  "sails": "^1.0.0-27",
  "sails-mysql": "^1.0.0-7",
  "waterline": "v0.13.0-rc4"
}

1 个答案:

答案 0 :(得分:4)

sails-mysqlwaterline-schemawaterline模块进行逆向工程后,我发现无法在autoMigrations属性中设置索引。如下:

foo: { 
  type: 'number'
  autoMigrations: { index: true }
}