So my / config / models look like this.
Person name Text Car name Text PersonCar personId PersionId eq carId CarId eq UniquePersonCar personId carId
Suppose the entries in the database are Person "Batman" Person "Superman" Car "SUV" Car "Ford" respectively.
I am currently doing this to link them in my handler.
runDB $ do person <- selectFirst [PersonName ==. "Batman"] [] car <- selectFirst [Carname ==. "SUV"] [] let Entity personId _ = case person of Just info -> infor Nothing -> error "no such Person" let Entity carId _ = case car of Just info -> infor Nothing -> error "no such Car" _ <- insert $ PersonCar personId carId
Is there an easier way to do this? Is there an agreement for such an expression?
haskell yesod persistent
Hhc
source share