Module

Data.Postgres.Result

Package
purescript-postgresql
Repository
cakekindel/purescript-postgresql

#rowsAffected Source

rowsAffected :: Result -> Maybe Int

Returns the number of rows affected by the query

https://node-postgres.com/apis/result#resultrowcount-int--null

#FromRows Source

class FromRows a  where

Members

Instances

#FromRow Source

class FromRow (a :: Type)  where

Can be unmarshalled from a queried row

Implementations are provided for:

  • tuples of any length containing types that are Rep
  • tuples of any length with the last member of Array Raw
  • a single value of a type that is Rep
  • Array Raw
  • Unit (always succeeds)
-- CREATE TABLE foo
--   ( id INT NOT NULL PRIMARY KEY
--   , fruit TEXT NOT NULL
--   , created TIMESTAMPTZ NOT NULL DEFAULT NOW()
--   );
do
  let q = query "select id, fruit, created from foo" client

  -- pick all 3 columns explicitly
  _ :: Array (Int /\ String /\ DateTime) <- q

  -- pick first 2 columns, discarding any others
  _ :: Array (Int /\ String) <- q

  -- pick first 2 columns, if any more keep as `Array Raw`
  _ :: Array (Int /\ String /\ Array Raw) <- q

  -- pick just the ID, discarding all other columns
  id :: Array Int <- q

  pure unit

Members

Instances

#__rowsAffected Source

__rowsAffected :: Result -> Nullable Number

FFI binding for Result#rowCount

#rows Source

rows :: Result -> Array (Array Raw)

FFI binding for Result#rows