diff --git a/docs/QuickStart.md b/docs/QuickStart.md index fab67f3d..6a7651e2 100644 --- a/docs/QuickStart.md +++ b/docs/QuickStart.md @@ -128,23 +128,23 @@ engine.SetColumnMapper(SnakeMapper{}) ### 2.2.Prefix mapping, Suffix Mapping and Cache Mapping -* 通过`engine.NewPrefixMapper(SnakeMapper{}, "prefix")`可以在SnakeMapper的基础上在命名中添加统一的前缀,当然也可以把SnakeMapper{}换成SameMapper或者你自定义的Mapper。 -* 通过`engine.NewSufffixMapper(SnakeMapper{}, "suffix")`可以在SnakeMapper的基础上在命名中添加统一的后缀,当然也可以把SnakeMapper{}换成SameMapper或者你自定义的Mapper。 -* 通过`eneing.NewCacheMapper(SnakeMapper{})`可以起到在内存中缓存曾经映射过的命名映射。 +* `engine.NewPrefixMapper(SnakeMapper{}, "prefix")` can add prefix string when naming based on SnakeMapper or SameMapper, or you custom Mapper. +* `engine.NewPrefixMapper(SnakeMapper{}, "suffix")` can add suffix string when naming based on SnakeMapper or SameMapper, or you custom Mapper. +* `engine.NewCacheMapper(SnakeMapper{})` add naming Mapper for memory cache. -当然,如果你使用了别的命名规则映射方案,也可以自己实现一个IMapper。 +Of course, you can implement IMapper to make custom naming strategy. ### 2.3.Tag mapping -如果所有的命名都是按照IMapper的映射来操作的,那当然是最理想的。但是如果碰到某个表名或者某个字段名跟映射规则不匹配时,我们就需要别的机制来改变。 +It's idealized of using IMapper for all naming. But if table or column is not in rule, we need new method to archive. -通过`engine.Table()`方法可以改变struct对应的数据库表的名称,通过sturct中field对应的Tag中使用`xorm:"'table_name'"`可以使该field对应的Column名称为指定名称。这里使用两个单引号将Column名称括起来是为了防止名称冲突,因为我们在Tag中还可以对这个Column进行更多的定义。如果名称不冲突的情况,单引号也可以不使用。 +`engine.Table()` can change the database table name for struct. The struct tag `xorm:"'table_name'"` can set column name for struct field. Use a pair of single quotes to prevent confusion for column's definition in struct tag. If not in confusion, ignore single quotes. -### 2.4.Column defenition +### 2.4.Column definition -我们在field对应的Tag中对Column的一些属性进行定义,定义的方法基本和我们写SQL定义表结构类似,比如: +Struct tag defines something for column as basic sql concepts, such as : ``` type User struct { @@ -153,9 +153,9 @@ type User struct { } ``` -For different DBMS, data types对于不同的数据库系统,数据类型其实是有些差异的。因此xorm中对数据类型有自己的定义,基本的原则是尽量兼容各种数据库的字段类型,具体的字段对应关系可以查看[字段类型对应表](https://github.com/go-xorm/xorm/blob/master/docs/COLUMNTYPE.md)。 +Data types are different in different DBMS. So xorm makes own data types definition to keep compatible. Details is in document [Column Types](https://github.com/go-xorm/xorm/blob/master/docs/COLUMNTYPE.md). -具体的映射规则如下,另Tag中的关键字均不区分大小写,字段名区分大小写: +The following table is field mapping rules, the keyword is not case sensitive except column name:
pk | If column is Primary Key | ||
当前支持30多种字段类型,详情参见 [字段类型](https://github.com/go-xorm/xorm/blob/master/docs/COLUMNTYPE.md) | 字段类型 | +support over 30 kinds of column types, details in [Column Types](https://github.com/go-xorm/xorm/blob/master/docs/COLUMNTYPE.md) | column type |
autoincr | If autoincrement column | @@ -174,22 +174,22 @@ For different DBMS, data types对于不同的数据库系统,数据类型其[not ]null | notnull | if column could be blank |
unique/unique(uniquename) | 是否是唯一,如不加括号则该字段不允许重复;如加上括号,则括号中为联合唯一索引的名字,此时如果有另外一个或多个字段和本unique的uniquename相同,则这些uniquename相同的字段组成联合唯一索引 | +unique/unique(uniquename) | column is Unique index; if add (uniquename), the column is used for combined unique index with the field that defining same uniquename. |
index/index(indexname) | 是否是索引,如不加括号则该字段自身为索引,如加上括号,则括号中为联合索引的名字,此时如果有另外一个或多个字段和本index的indexname相同,则这些indexname相同的字段组成联合索引 | +index/index(indexname) | column is index. if add (indexname), the column is used for combined index with the field that defining same indexname. |
extends | 应用于一个匿名结构体之上,表示此匿名结构体的成员也映射到数据库中 | +extends | use for anonymous field, map the struct in anonymous field to database |
- | This field will not be mapping | ||
-> | 这个Field将只写入到数据库而不从数据库读取 | +-> | only write into database |
<- | 这个Field将只从数据库读取,而不写入到数据库 | +<- | only read from database |
created | This field will be filled in current time on insert | @@ -205,16 +205,17 @@ For different DBMS, data types对于不同的数据库系统,数据类型其