Hoogle Search

Within LTS Haskell 24.27 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. selectList :: forall record backend (m :: Type -> Type) . (MonadIO m, PersistQueryRead backend, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m [Entity record]

    persistent Database.Persist.Class.PersistQuery

    Returns a [Entity record] corresponding to the filters and options provided. Filters are constructed using the operators defined in Database.Persist (and re-exported from Database.Persist.Sql). Let's look at some examples:

    usersWithAgeOver40 :: SqlPersistT IO [Entity User]
    usersWithAgeOver40 =
    selectList [UserAge >=. 40] []
    
    If you provide multiple values in the list, the conditions are ANDed together.
    usersWithAgeBetween30And50 :: SqlPersistT IO [Entity User]
    usersWithAgeBetween30And50 =
    selectList
    [ UserAge >=. 30
    , UserAge <=. 50
    ]
    []
    
    The second list contains the SelectOpt for a record. We can select the first ten records with LimitTo
    firstTenUsers =
    selectList [] [LimitTo 10]
    
    And we can select the second ten users with OffsetBy.
    secondTenUsers =
    selectList [] [LimitTo 10, OffsetBy 10]
    
    Warning that LIMIT/OFFSET is bad for pagination! The type of record can usually be infered from the types of the provided filters and select options. In the previous two examples, though, you'll notice that the select options are polymorphic, applying to any record type. In order to help type inference in such situations, or simply as an enhancement to readability, you might find type application useful, illustrated below.
    {-# LANGUAGE TypeApplications #-}
    ...
    
    firstTenUsers =
    selectList User [] [LimitTo 10]
    
    secondTenUsers =
    selectList User [] [LimitTo 10, OffsetBy 10]
    
    With Asc and Desc, we can provide the field we want to sort on. We can provide multiple sort orders - later ones are used to sort records that are equal on the first field.
    newestUsers =
    selectList [] [Desc UserCreatedAt, LimitTo 10]
    
    oldestUsers =
    selectList [] [Asc UserCreatedAt, LimitTo 10]
    

  2. PersistList :: [PersistValue] -> PersistValue

    persistent Database.Persist.PersistValue

    No documentation available.

  3. FieldListHasReferences :: NonEmpty ForeignFieldReference -> UnboundForeignFieldList

    persistent Database.Persist.Quasi.Internal

    You can specify the exact columns you're referring to here, if they aren't part of a primary key. Most databases expect a unique index on the columns you refer to, but Persistent doesnt' check that.

    User
    Id           UUID default="uuid_generate_v1mc()"
    name         Text
    
    UniqueName name
    
    Dog
    ownerName    Text
    
    Foreign User fk_dog_user ownerName References name
    

  4. FieldListImpliedId :: NonEmpty FieldNameHS -> UnboundForeignFieldList

    persistent Database.Persist.Quasi.Internal

    If no References keyword is supplied, then it is assumed that you are referring to the Primary key or Id of the target entity.

  5. data UnboundForeignFieldList

    persistent Database.Persist.Quasi.Internal

    A list of fields present on the foreign reference.

  6. mkEntityDefList :: String -> [UnboundEntityDef] -> Q [Dec]

    persistent Database.Persist.TH

    Creates a declaration for the [EntityDef] from the persistent schema. This is necessary because the Persistent QuasiQuoter is unable to know the correct type of ID fields, and assumes that they are all Int64. Provide this in the list you give to share, much like mkMigrate.

    share [mkMigrate "migrateAll", mkEntityDefList "entityDefs"] [...]
    

  7. mkEntityDefList :: String -> [UnboundEntityDef] -> Q [Dec]

    persistent Database.Persist.TH.Internal

    Creates a declaration for the [EntityDef] from the persistent schema. This is necessary because the Persistent QuasiQuoter is unable to know the correct type of ID fields, and assumes that they are all Int64. Provide this in the list you give to share, much like mkMigrate.

    share [mkMigrate "migrateAll", mkEntityDefList "entityDefs"] [...]
    

  8. FTList :: FieldType -> FieldType

    persistent Database.Persist.Types

    No documentation available.

  9. PersistList :: [PersistValue] -> PersistValue

    persistent Database.Persist.Types

    No documentation available.

  10. module Data.DList

    No documentation available.

Page 66 of many | Previous | Next