1{-# LANGUAGE ConstraintKinds #-} 2module Database.Persist.Class 3 ( ToBackendKey (..) 4 5 -- * PersistStore 6 -- | 7 -- 8 -- All the examples present here will be explained based on these schemas, datasets and functions: 9 -- 10 -- = schema-1 11 -- 12 -- #schema-persist-store-1# 13 -- 14 -- > share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| 15 -- > User 16 -- > name String 17 -- > age Int 18 -- > deriving Show 19 -- > |] 20 -- 21 -- = dataset-1 22 -- 23 -- #dataset-persist-store-1# 24 -- 25 -- > +----+-------+-----+ 26 -- > | id | name | age | 27 -- > +----+-------+-----+ 28 -- > | 1 | SPJ | 40 | 29 -- > +----+-------+-----+ 30 -- > | 2 | Simon | 41 | 31 -- > +----+-------+-----+ 32 33 , PersistCore (..) 34 , PersistStore 35 , PersistStoreRead (..) 36 , PersistStoreWrite (..) 37 , PersistRecordBackend 38 , getJust 39 , getJustEntity 40 , getEntity 41 , belongsTo 42 , belongsToJust 43 , insertEntity 44 , insertRecord 45 46 -- * PersistUnique 47 -- | 48 -- 49 -- All the examples present here will be explained based on these two schemas and the dataset: 50 -- 51 -- = schema-1 52 -- This schema has single unique constraint. 53 -- 54 -- #schema-persist-unique-1# 55 -- 56 -- > share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| 57 -- > User 58 -- > name String 59 -- > age Int 60 -- > UniqueUserName name 61 -- > deriving Show 62 -- > |] 63 -- 64 -- = schema-2 65 -- This schema has two unique constraints. 66 -- 67 -- #schema-persist-unique-2# 68 -- 69 -- > share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase| 70 -- > User 71 -- > name String 72 -- > age Int 73 -- > UniqueUserName name 74 -- > UniqueUserAge age 75 -- > deriving Show 76 -- > |] 77 -- 78 -- = dataset-1 79 -- 80 -- #dataset-persist-unique-1# 81 -- 82 -- > +-----+-----+-----+ 83 -- > |id |name |age | 84 -- > +-----+-----+-----+ 85 -- > |1 |SPJ |40 | 86 -- > +-----+-----+-----+ 87 -- > |2 |Simon|41 | 88 -- > +-----+-----+-----+ 89 90 , PersistUnique 91 , PersistUniqueRead (..) 92 , PersistUniqueWrite (..) 93 , OnlyOneUniqueKey (..) 94 , AtLeastOneUniqueKey (..) 95 , NoUniqueKeysError 96 , MultipleUniqueKeysError 97 , getByValue 98 , insertBy 99 , insertUniqueEntity 100 , replaceUnique 101 , checkUnique 102 , onlyUnique 103 104 -- * PersistQuery 105 , PersistQuery 106 , PersistQueryRead (..) 107 , PersistQueryWrite (..) 108 , selectSource 109 , selectKeys 110 , selectList 111 , selectKeysList 112 113 -- * DeleteCascade 114 , DeleteCascade (..) 115 , deleteCascadeWhere 116 117 -- * PersistEntity 118 , PersistEntity (..) 119 -- * PersistField 120 , PersistField (..) 121 -- * PersistConfig 122 , PersistConfig (..) 123 , entityValues 124 125 -- * Lifting 126 , HasPersistBackend (..) 127 , IsPersistBackend () 128 , liftPersist 129 , BackendCompatible (..) 130 131 -- * JSON utilities 132 , keyValueEntityToJSON, keyValueEntityFromJSON 133 , entityIdToJSON, entityIdFromJSON 134 , toPersistValueJSON, fromPersistValueJSON 135 ) where 136 137import Database.Persist.Class.DeleteCascade 138import Database.Persist.Class.PersistConfig 139import Database.Persist.Class.PersistEntity 140import Database.Persist.Class.PersistField 141import Database.Persist.Class.PersistQuery 142import Database.Persist.Class.PersistStore 143import Database.Persist.Class.PersistUnique 144 145 146-- | A backwards-compatible alias for those that don't care about distinguishing between read and write queries. 147-- It signifies the assumption that, by default, a backend can write as well as read. 148type PersistUnique a = PersistUniqueWrite a 149 150-- | A backwards-compatible alias for those that don't care about distinguishing between read and write queries. 151-- It signifies the assumption that, by default, a backend can write as well as read. 152type PersistQuery a = PersistQueryWrite a 153 154-- | A backwards-compatible alias for those that don't care about distinguishing between read and write queries. 155-- It signifies the assumption that, by default, a backend can write as well as read. 156type PersistStore a = PersistStoreWrite a 157