You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_, affected, err:= orm.ExecRaw[Post](`DELETE FROM posts WHERE id=?`, 1)
166
166
```
167
167
### Relationships
168
-
GolobbyORM makes it easy to have entities that have relationships with each other. As you have already seen in entity definition
169
-
you have a `ConfigureRelations` method which let's you define relations of an `Entity`.
168
+
GolobbyORM makes it easy to have entities that have relationships with each other. Configuring relations is using `ConfigureEntity` method as you will see.
As you can see we are defining a `Post` entity which has a `HasMany` relation with `Comment`. You can configure how GolobbyORM queries `HasMany` relation with `orm.HasManyConfig` object, by default it will infer all fields for you.
179
178
now you can use this relationship anywhere in your code.
180
179
```go
181
-
comments, err:= orm.HasMany[Comment](post)
180
+
comments, err:= orm.HasMany[Comment](post).All()
181
+
```
182
+
`HasMany` and other relation functions in GolobbyORM return `QueryBuilder` and you can use them like other query builders and create even more
183
+
complex queries for relationships. for example you can create a query for getting all comments of a post that are created today.
0 commit comments