goooqo-demo

command module
v0.0.0-...-e3504ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

README

License

Demo for GoooQo

Introduction

This repo shows how to use GoooQo to access a single table.

The test.db is a database of sqlite which contains a simple table t_user with 4 rows.

id username email nickname memo valid
1 f0rb f0rb@163.com test1 true
2 user2 test2@qq.com test2 false
3 user3 test3@qq.com test3 memo true
4 user4 test4@qq.com test4 true

With GoooQo, we only need to define the structs UserEntity and UserQuery in user.go, where UserEntity corresponds to the table t_user and UserQuery is used to build the query clause. The goooqo.PageQuery embedded in UserQuery helps to implement sorting and paging operations.

Then we build the web APIs listened on http://localhost:9090/user/ by the following two lines:

userDataAccess := rdb.NewTxDataAccess[UserEntity](tm)
goooqo.BuildRestService[UserEntity, UserQuery]("/user/", userDataAccess)

Run the main method in demo.go and visit the the following URLs to check the response:

And there are also some sample POST/PUT/PATCH/DELETE operations listed in user.http to take a try.

NOTE:The web module of GoooQo is for tests and demos only, not a core feature.

License

This project is under the Apache Licence v2.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL