Kaltsoon / sequelize-cursor-pagination

➡️ Cursor-based pagination queries for Sequelize models
86 stars 27 forks source link

composite primary keys #40

Closed sm2017 closed 3 years ago

sm2017 commented 3 years ago
const options = {
  methodName: 'paginate',
  primaryKeyField: 'id',
};

How can I set primaryKeyField for composite primary keys?

Kaltsoon commented 3 years ago

With composite primary keys, you can have one of the keys as the primaryKeyField and other should be present in the order. The primaryKeyFieldoption is used to ensure that table's primary key is in the order (see here). Because at the moment the primaryKeyField option doesn't support composite primary keys you'll have to include it in the order per query basis.

Kaltsoon commented 3 years ago

Version 2.3.0 now supports composite primary keys with primaryKeyField: ['key1', 'key2']. Enjoy!