You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

811 B

2.2. Prefix mapping, Suffix Mapping and Cache Mapping

Decorated mappers can be created based on existing names.Mapper classes.

  • names.NewPrefixMapper(namesSnakeMapper{}, "prefix") can add prefix string when naming based on SnakeMapper or SameMapper, or your custom Mapper.

For example,

tbMapper := names.NewPrefixMapper(names.SnakeMapper{}, "prefix_")
engine.SetTableMapper(tbMapper)

Then struct type User struct will be mapping to table prefix_user but not user.

  • names.NewSuffixMapper(names.SnakeMapper{}, "suffix") can add suffix string when naming based on SnakeMapper or SameMapper, or your custom Mapper.
  • names.NewCacheMapper(names.SnakeMapper{}) can add a memory cache to an existing mapper.

Of course, you can implement IMapper to create a custom naming strategy.