alex-tan/postgrest-queries/2.0.0

NOTE: the latest version is 7.2.0

Postgrest.Queries

An individual postgrest parameter.

A collection of parameters that make up a postgrest request.

A type representing which attributes and resources you want to select.

When you want to select all attributes. This is only useful when used to select attributes of a resource or override default parameters in another function since postgrest returns all attributes by default.

When you want to select a certain column.

attributes : List String -> List PostgrestSelectable

Shorthand for attributes, when you don't need to specify nested resources:

-- Short version
attributes [ "id" "name" ]


-- Long version
[ attribute "id"
, attribute "name"
]
combineParams : PostgrestParams -> PostgrestParams -> PostgrestParams

Takes a default set of params and a custom set of params and prefers the second set. Useful when you're constructing reusable functions that make similar queries.

desc : String -> ColumnOrder

Used in combination with order to sort results descending.

eq : PostgrestValue -> PostgrestClause

Used to indicate you need a column to be equal to a certain value.

gt : Float -> PostgrestClause

Used to indicate you need a column to be greater than a certain value.

gte : Float -> PostgrestClause

Used to indicate you need a column to be greater than or equal than a certain value.

inList : (a -> PostgrestValue) -> List a -> PostgrestClause

Used to indicate you need a column to be within a certain list of values.

int : Int -> PostgrestValue

Normalize an int into a postgrest value.

A constructor for the limit parameter.

limit 10
lt : Float -> PostgrestClause

Used to indicate you need a column to be less than a certain value.

lte : Float -> PostgrestClause

Used to indicate you need a column to be less than or equal than a certain value.

neq : PostgrestValue -> PostgrestClause

Used to indicate you need a column to be not equal to a certain value.

normalizeParams : PostgrestParams -> List ( String, String )

Takes PostgrestParams and returns the parameters as a list of (Key, Value) strings.

A constructor for the limit parameter.

order (asc "name")


order (desc "name")

Join multiple conditions together with or.

Join multiple conditions together with and.

param : String -> PostgrestClause -> PostgrestParam

A constructor for an individual postgrest parameter.

param "name" (eq (string "John"))

When you want to select a nested resource.

A constructor for the select parameter.

P.select
    [ P.attribute "id"
    , P.attribute "title"
    , P.resource "user" <|
        P.attributes
            [ "email"
            , "name"
            ]
    ]
string : String -> PostgrestValue

Normalize a string into a postgrest value.

true : PostgrestClause

When you need a column value to be true

value : PostgrestValue -> PostgrestClause

When you don't want to use a specific type after the equals sign in the query, you can use value to set anything you want.

A type to specify whether you want an order to be ascending or descending.