* Computes the cursor value for given entity and order definition.
(
meta: EntityMetadata<Entity>,
entity: FilterObject<Entity>,
orderBy: OrderDefinition<Entity>,
)
| 171 | * Computes the cursor value for given entity and order definition. |
| 172 | */ |
| 173 | static for<Entity extends object>( |
| 174 | meta: EntityMetadata<Entity>, |
| 175 | entity: FilterObject<Entity>, |
| 176 | orderBy: OrderDefinition<Entity>, |
| 177 | ): string { |
| 178 | const definition = this.getDefinition(meta, orderBy); |
| 179 | return Cursor.encode( |
| 180 | definition.map(([key]) => { |
| 181 | const value = entity[key]; |
| 182 | if (value === undefined) { |
| 183 | throw CursorError.missingValue(meta.className, key as string); |
| 184 | } |
| 185 | return value; |
| 186 | }), |
| 187 | ); |
| 188 | } |
| 189 | |
| 190 | static encode(value: unknown[]): string { |
| 191 | return Buffer.from(JSON.stringify(value)).toString('base64url'); |
no test coverage detected