0

I am trying to use Persistent to access my database. I know that Persistent can generate the code of entity, but there is something I can't generate so easily. Like I got a table which looks like:

CREATE TABLE `user` (
  `user_id` bigint(11) NOT NULL,
  `user_name` varchar(255) DEFAULT NULL,
  `user_password` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

then my haskell code like :

mkPersist sqlSettings [persistLowerCase|
User
  name String
  password String
  deriving Show
|]

These fields are different include the primary key, I want to set their mapping relation. The official page (https://www.yesodweb.com/book/persistent) doesn't say how to do it.

Need I write the code to define it instead of generating it?

Rein Henrichs
  • 15,437
  • 1
  • 45
  • 55
Jacky Wong
  • 481
  • 1
  • 3
  • 14

1 Answers1

0

I've found it on this page https://github.com/yesodweb/persistent/blob/master/docs/Persistent-entity-syntax.md

I can do some customization follow these syntax.

Jacky Wong
  • 481
  • 1
  • 3
  • 14