Skip to content

postgrelize / over

Function: over() ​

over(windowFunction, window?): Over

Defined in: src/expressions/methods.ts:212

postgrelize extension

Window function call: over(fn('row_number'), { partitionBy: ['userId'], orderBy: [['createdAt', 'DESC']] }). PostgreSQL extension.

Parameters ​

windowFunction ​

Literal | Fn

Function call, e.g. fn('rank').

window? ​

WindowOptions = {}

Partition and order.

Returns ​

Over

Expression usable in attributes and order.

Example ​

ts
await Post.findAll({
  attributes: ['id', [over(fn('row_number'), { partitionBy: ['userId'], orderBy: [['createdAt', 'DESC']] }), 'rank']],
});

Released under the MIT License.