Skip to main content


There are a number of common starter functions shared by all supported dialects:

  • S(string): Create a single quoted string literal.

    //  SQL: 'a string'
    psql.S("a string")
  • F(name string, args ...any): A function call. Takes a name and the arguments.

    //  SQL: generate_series(1, 3)
    psql.F("generate_series", 1, 3)
  • Not(Expression): Creates a NOT expr expression.

    //  SQL: Not a = b
    psql.Not("a = b")
  • OR(...Expression): Joins multiple expressions with "OR".

    // SQL: a OR b OR c
    psql.Or("a", "b", "c")
  • AND(...Expression): Joins multiple expressions with "AND"

    // SQL: a AND b AND c
    psql.And("a", "b", "c")
  • Arg(...any): One or more arguments. These are replaced with placeholders in the query and the args returned.

    // SQL: $1, $2, $3
    // Args: 'a', 'b', 'c'
    psql.Arg("a", "b", "c")
  • ArgGroup(...any): Similar to Arg but wraps the given set of arguments in parentheses.

    // SQL: ($1, $2), ($3, $4)
    // Args: ('a', 'b', 'c', 'd')
    psql.Group(psql.ArgGroup("a", "b"), psql.ArgGroup("c", "d"))
  • Placeholders(uint): Inserts a count of placeholders without any specific value yet. Useful for compiling reusable queries.

    // SQL: $1, $2, $3
    // Args: nil, nil, nil
  • Group(...Expression): To easily group a number of expressions. Wraps them in parentheses AND seperates them with commas.

    // SQL: (a, b, c)
    psql.Group("a", "b", "c")
  • Quote(...string): For quoting. See details

    // SQL: "table"."column
    psql.Quote("table", "column")
  • Raw(clause string, args ...any): For inserting a raw statement somewhere. To keep it dialect agnostic, placeholders should be inserted with ? and a literal question mark can be escaped with a backslash \?.

    // SQL: WHERE a = $1
    // Args: 'something'
    psql.Raw("WHERE a = ?", "something")

See dialect documentation for extra starters