Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some mark down enhancements #11

Merged
merged 2 commits into from
Mar 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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