diff --git a/README.md b/README.md index 1880bfd..be54541 100644 --- a/README.md +++ b/README.md @@ -125,9 +125,8 @@ type User struct { } func (u User) ConfigureEntity(e *orm.EntityConfigurator) { - e. - Table("users"). - Connection("default") // You can omit connection name if you only have one. + e.Table("users"). + Connection("default") // You can omit connection name if you only have one. } ``` @@ -165,6 +164,7 @@ GoLobby ORM for each struct field(except slice, arrays, maps, and other nested s If you want a custom column name, you should specify it in the entity struct. ```go package main + type User struct { Name string `orm:"column=username"` // now this field will be mapped to `username` column in sql database. } @@ -173,6 +173,7 @@ type User struct { GoLobby ORM assumes that each entity has a primary key named `id`; if you want a custom primary key called, you need to specify it in entity struct. ```go package main + type User struct { PK int64 `orm:"pk=true"` } @@ -232,8 +233,7 @@ res, err := orm.Query[User]().Where("id", 1).Update(orm.KV{"name": "amirreza2"}) ```go _, affected, err := orm.ExecRaw[User](`UPDATE users SET name=? WHERE id=?`, "amirreza", 1) ``` -``` -### Deleting entities +### Deleting entities It is also easy to delete entities from a database. ```go err := orm.Delete(user) @@ -305,6 +305,7 @@ func (p Post) ConfigureEntity(e *orm.EntityConfigurator) { } type Category struct{} + func(c Category) ConfigureEntity(r *orm.EntityConfigurator) { e.Table("categories").BelongsToMany(&Post{}, orm.BelongsToManyConfig{IntermediateTable: "post_categories"}) }