balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

How to ad id index if The `primaryKey` property can no longer be specified on an attribute in Sails 1.0. #7156

Open n4an opened 3 years ago

n4an commented 3 years ago

Node version: Sails version (sails): ORM hook version (sails-hook-orm): Sockets hook version (sails-hook-sockets): Organics hook version (sails-hook-organics): Grunt hook version (sails-hook-grunt): Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. sails-mysql@5.55.5): Skipper adapter & version (e.g. skipper-s3@5.55.5):


In the id attribute of model role: The primaryKey property can no longer be specified on an attribute in Sails 1.0. If you want to declare id to be the primary key of role, set primaryKey: 'id' at the top level of the model.

sailsbot commented 3 years ago

@Mitch-i Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

n4an commented 3 years ago

Or is not need

primary key is automatically indexed in MySQL because primary key, index, etc gets stored into B-trees. All engines including InnoDB as well as MyISAM automatically supports the primary key to be indexed.

eashaw commented 3 years ago

Hi @Mitch-i, You can specify a primaryKey by setting primaryKey: 'someAttribute', at the top level of the model.

https://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?primarykey