Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.06 KB

README.md

File metadata and controls

45 lines (35 loc) · 1.06 KB

Dashdot Cursors

build codecov

A simple SQL and Mongo implementation of cursor based pagination

Usage

Inside your Node project directory, run the following:

npm i --save @dashdot/cursors

Or with Yarn:

yarn add @dashdot/cursors

API

import { cursorToSqlQuery } from '@dashdot/cursor'
import * as tables from './tables'

const user = await tables.users().fist()
const orderBy = {
    email: 'ASC'
    lastName: 'DESC',
    firstName: 'ASC',
    id: 'DESC',
}
const cursor = createCursor(user, orderBy)
const [
    whereQuery,
    whereValues,
    orderQuery
]  = cursorToSqlQuery(cursor, orderBy)
const nextUser = await tables.users()
    .whereRaw(whereQuery, whereValues)
    .orderByRaw(orderQuery)
    .first()