Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Entry-level functions for executing based CRUD operations on entity tables. These are the functions that you will use most often for interacting with tables.
Since: 1.0.0.0
Synopsis
- insertEntity :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m ()
- insertEntityAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m Int
- insertAndReturnEntity :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m readEntity
- insertEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m ()
- insertAndReturnEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m [readEntity]
- insertEntitiesAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m Int
- updateEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m ()
- updateEntityAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m Int
- updateAndReturnEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m (Maybe readEntity)
- updateFields :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m ()
- updateFieldsAndReturnEntities :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m [readEntity]
- updateFieldsAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m Int
- deleteEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m ()
- deleteEntityAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m Int
- deleteAndReturnEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m (Maybe readEntity)
- deleteEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m ()
- deleteEntitiesAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m Int
- deleteAndReturnEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m [readEntity]
- findEntitiesBy :: MonadOrville m => TableDefinition key writeEntity readEntity -> SelectOptions -> m [readEntity]
- findFirstEntityBy :: MonadOrville m => TableDefinition key writeEntity readEntity -> SelectOptions -> m (Maybe readEntity)
- findEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m (Maybe readEntity)
- findEntities :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty key -> m [readEntity]
Documentation
insertEntity :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m () Source #
Inserts an entity into the specified table.
Since: 1.0.0.0
insertEntityAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m Int Source #
Inserts an entity into the specified table. Returns the number of rows affected by the query.
Since: 1.0.0.0
insertAndReturnEntity :: MonadOrville m => TableDefinition key writeEntity readEntity -> writeEntity -> m readEntity Source #
Inserts an entity into the specified table, returning the data inserted into the database.
You can use this function to obtain any column values filled in by the database, such as auto-incrementing ids.
Since: 1.0.0.0
insertEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m () Source #
Inserts a non-empty list of entities into the specified table.
Since: 1.0.0.0
insertAndReturnEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m [readEntity] Source #
Inserts a non-empty list of entities into the specified table, returning the data that was inserted into the database.
You can use this function to obtain any column values filled in by the database, such as auto-incrementing ids.
Since: 1.0.0.0
insertEntitiesAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> NonEmpty writeEntity -> m Int Source #
Inserts a non-empty list of entities into the specified table. Returns the number of rows affected by the query.
Since: 1.0.0.0
updateEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m () Source #
Updates the row with the given key with the data given by writeEntity
.
Since: 1.0.0.0
updateEntityAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m Int Source #
Updates the row with the given key with the data given by writeEntity
.
Returns the number of rows affected by the query.
Since: 1.0.0.0
updateAndReturnEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> writeEntity -> m (Maybe readEntity) Source #
Updates the row with the given key with the data given by writeEntity
,
returning the updated row from the database. If no row matches the given key,
Nothing
will be returned.
You can use this function to obtain any column values computed by the database during the update, including columns with triggers attached to them.
Since: 1.0.0.0
updateFields :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m () Source #
updateFieldsAndReturnEntities :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m [readEntity] Source #
Like updateFields
, but uses a RETURNING
clause to return the updated
version of any rows that were affected by the update.
Since: 1.0.0.0
updateFieldsAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty SetClause -> Maybe BooleanExpr -> m Int Source #
deleteEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m () Source #
Deletes the row with the given key.
Since: 1.0.0.0
deleteEntityAndReturnRowCount :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m Int Source #
Deletes the row with the given key. Returns the number of rows affected by the query.
Since: 1.0.0.0
deleteAndReturnEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m (Maybe readEntity) Source #
Deletes the row with the given key, returning the row that was deleted.
If no row matches the given key, Nothing
is returned.
Since: 1.0.0.0
deleteEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m () Source #
Deletes all rows in the given table that match the where condition.
Since: 1.0.0.0
deleteEntitiesAndReturnRowCount :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m Int Source #
Deletes all rows in the given table that match the where condition. Returns the number of rows affected by the query.
Since: 1.0.0.0
deleteAndReturnEntities :: MonadOrville m => TableDefinition key writeEntity readEntity -> Maybe BooleanExpr -> m [readEntity] Source #
Deletes all rows in the given table that match the where condition, returning the rows that were deleted.
Since: 1.0.0.0
findEntitiesBy :: MonadOrville m => TableDefinition key writeEntity readEntity -> SelectOptions -> m [readEntity] Source #
Finds all the entities in the given table according to the specified
SelectOptions
, which may include where conditions to
match, ordering specifications, etc.
Since: 1.0.0.0
findFirstEntityBy :: MonadOrville m => TableDefinition key writeEntity readEntity -> SelectOptions -> m (Maybe readEntity) Source #
Like findEntitiesBy
, but adds a 'LIMIT 1' to the query and then returns
the first item from the list. Usually when you use this you will want to
provide an order by clause in the SelectOptions
because the
database will not guarantee ordering.
Since: 1.0.0.0
findEntity :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> key -> m (Maybe readEntity) Source #
Finds a single entity by the table's primary key value.
Since: 1.0.0.0
findEntities :: MonadOrville m => TableDefinition (HasKey key) writeEntity readEntity -> NonEmpty key -> m [readEntity] Source #
Finds multiple entities by the table's primary key.
Since: 1.0.0.0