Table of contents
  1. One Clause
  2. Two Clauses
    1. One call
    2. Two calls
import { table, dsql as sql } from "../../src";

We will use this table

CREATE TABLE users(id int, age int, name string);

Which is defined in typescript as

const users = table(["id", "age", "name"], "users");

One Clause

users
    .selectStar()
    .orderBy((f) => f.age)
    .stringify();
SELECT
  *
FROM
  `users`
ORDER BY
  `age`

Two Clauses

One call

users
    .selectStar()
    .orderBy((f) => [sql`${f.age} DESC`, f.id])
    .stringify();
SELECT
  *
FROM
  `users`
ORDER BY
  `age` DESC,
  `id`

Two calls

users
    .selectStar()
    .orderBy((f) => f.age)
    .orderBy((f) => f.id)
    .stringify();
SELECT
  *
FROM
  `users`
ORDER BY
  `age`,
  `id`
users.selectStar().orderBy(["age", "id"]).stringify();
SELECT
  *
FROM
  `users`
ORDER BY
  `age`,
  `id`

This document used eval-md