lykahb / groundhog

This library maps datatypes to a relational model, in a way similar to what ORM libraries do in OOP. See the tutorial https://www.schoolofhaskell.com/user/lykahb/groundhog for introduction
http://hackage.haskell.org/package/groundhog
176 stars 39 forks source link

entityDef should get the Proxy #95

Closed yaitskov closed 4 years ago

yaitskov commented 4 years ago

Hi,

I am trying to use Groundhog for sharded tables. Lot's of tables with same structure, but different names.

PersistentEntity has entitfyDef function it gets undefined value in case of select operation. When value is persisted last argument gets normal value and I can get table name from there to figure out in which table to store the value.

I found that the reflection library allows to pass configuration (table name in my case) through out the proxy value.

I have no clue how to construct a type with phantom type variable in runtime.

Special thanks for the feature - table without primary key.

lykahb commented 4 years ago

Are you looking how to create the value of v or proxy db? You can create them as undefined :: Mytype or undefined :: proxy db. When the values are not available, XScopedTypeVariables extension is quite handy.

yaitskov commented 4 years ago

undefined :: Mytype trick is working for compile time. I have a dynamic set of table names. New tables are created on demand. i.e. I cannot feed value from stdin into phantom parameter of Mytype.