Releases: doytowin/goooqo
Releases · doytowin/goooqo
v0.2.3
What's Changed
- Support querying entities with related entities by abstract entity path tag.
- Support CRUD for association tables.
- Rename
gen
togooogen
as a go:generate tool. - Enhance generation for SQL builder.
Usages:
gooogen
- Define the
go:generate gooogen
command before a query struct:
//go:generate gooogen
type UserQuery struct {
PageQuery
IdGt *int
IdIn *[]int
//...
}
- Run the
go generate
command to generate the corresponding query construction methods in the specified file.
Check the README or the document for more details.
v0.2.2
Versions
- core/v0.2.2
- rdb/v0.2.2
- web/v0.2.2
Features
rdb
- support many-to-many/one-to-many/many-to-one/one-to-one queries
- ignore blank strings for the LIKE condition
- ignore empty splices for In/NotIn
- remove suffix Not
web
- make ResolveQuery public
Example for ER queries
Table t_menu
has a column parent_id
referring to the id
column itself as a foreign key.
The parent_id
column is used to define the hierarchical parent-child relationship between menu items.
The menus are assigned to the users as a system resource via a general RBAC model.
import . "github.com/doytowin/goooqo/core"
type MenuEntity struct {
IntId
ParentId *int `json:"parentId,omitempty"`
Name *string `json:"name,omitempty"`
}
type MenuQuery struct {
PageQuery
Id *int
// many-to-one:
// Query the submenus of a specific parent menu:
// parent_id IN (SELECT id FROM t_menu WHERE [conditions])
Parent *MenuQuery `entitypath:"menu" localField:"ParentId"`
// one-to-many:
// Query the parent menu of a specific submenu:
// id IN (SELECT parent_id FROM t_menu WHERE [conditions])
Children *MenuQuery `entitypath:"menu" foreignField:"ParentId"`
/**
many-to-many:
Query the menus accessible to a specific user:
id IN (
SELECT menu_id FROM a_perm_and_menu WHERE perm_id IN (
SELECT perm_id FROM a_role_and_perm WHERE role_id IN (
SELECT role_id FROM a_user_and_role WHERE user_id IN (
SELECT id FROM t_user WHERE [conditions]
)
)
)
)*/
User *UserQuery `entitypath:"menu,perm,role,user"`
}
For more details. check https://goooqo.docs.doyto.win/query-mapping/query-object/er-query-field .
v0.2.2-pre.1
test
v0.2.0
Features:
- support subquery field mapping
- Tag:
subquery
- Tag:
select
/from
- Condition from name
- ANY
- ALL
- Tag:
Examples for subquery mapping:
type UserQuery struct {
PageQuery
//...
ScoreLtAvg *UserQuery `subquery:"select avg(score) from User"`
ScoreLtAny *UserQuery `subquery:"SELECT score FROM User"`
ScoreLtAll *UserQuery `subquery:"select score from UserEntity"`
ScoreGtAvg *UserQuery `select:"avg(score)" from:"UserEntity"`
ScoreInScoreOfUser *UserQuery
ScoreGtAvgScoreOfUser *UserQuery
}
Full Changelog: v0.1.4...v0.2.0
v0.1.4
Full Changelog: v0.1.3...v0.1.4
- add config for JSON intent
- recover for panic transaction
- add callback style transaction
- [core] add IntId
- [rdb] refactor SQL logging
- [rdb] Build Or Clause with And
- [rdb] Build Or Clause for basic type array
- [rdb] Build OR clause for struct array
v0.1.3
Full Changelog: v0.1.2...v0.1.3
- [core] export Int64Id
- [web] support PATCH /user/
- [web] support DELETE /user/
- [web] support lowercase for parameter names
- [rdb] support suffix Rx
- [rdb] fix type for field ending with Null
- [gen] add GenerateCodeToFile
- [gen] support rdb Null with *bool
v0.1.2
GoooQo-0.1.1
- Add transaction support
- Add subquery support
- Add custom clause support
- Add sort support
- Support Count/Create/Update/Patch/Delete
- Support suffix Like|NotLike|Contain|NotContain|Start|NotStart|End|NotEnd
- Add web module