Reputation: 2706
Basically right now I run fbId <- runDB $ insert myNewFooBar
and I get back a Key FooBar
. Is there any way to return the value of the whole FooBar
directly from an insert without running a separate query of runDB $ get404 fbId
after?
Upvotes: 1
Views: 175
Reputation: 7920
Another, shorter option is to use insertEntity
, which returns an entity instead of a record. Under the hood this function calls insert
and builds an entity from the supplied record and the returned key (no additional DB queries).
insertedFooBar <- runDB $ insertEntity myNewFooBar
Upvotes: 1