So my /config/models looks like this.
Person
name Text
Car
name Text
PersonCar
personId PersionId eq
carId CarId eq
UniquePersonCar personId carId
Assume the inputs in the database are Person "Batman"
Person "Superman"
Car "SUV"
Car "Ford"
respectively.
I'm currently doing this to link them up 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 a convention for doing such expression?
No, there's currently no shorthand for this kind of a query (that I can think of, at least).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With