Skip to content

Commit

Permalink
Merge pull request #11 from majidalaeinia/master
Browse files Browse the repository at this point in the history
Some mark down enhancements
  • Loading branch information
miladrahimi committed Mar 17, 2022
2 parents 54e6481 + 22c9721 commit 01674a2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
```
Expand Down Expand Up @@ -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.
}
Expand All @@ -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"`
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"})
}
Expand Down

0 comments on commit 01674a2

Please sign in to comment.