Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sphireinc/godex
A simple utility for creating and storing reusable queries
https://github.com/sphireinc/godex
Last synced: 3 days ago
JSON representation
A simple utility for creating and storing reusable queries
- Host: GitHub
- URL: https://github.com/sphireinc/godex
- Owner: sphireinc
- License: gpl-3.0
- Created: 2023-01-16T01:41:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-18T13:41:37.000Z (almost 2 years ago)
- Last Synced: 2024-11-09T20:34:18.155Z (2 months ago)
- Language: Go
- Homepage:
- Size: 36.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Godex
Godex provides a simple utility for creating and storing reusable queries
### Example
##### Creating a Codex
```go
q := Codex{
Table: "posts",
DefaultQueries: DefaultQueries{
SelectById: "SELECT * FROM posts WHERE id = :id",
SelectOne: "SELECT * FROM posts WHERE id = :id and post_title = :post_title",
Select: "SELECT * FROM posts WHERE created_at > '2020-05-10 12:23:43'",
Insert: "INSERT INTO posts(post_id) VALUES (:post_id)",
Update: "UPDATE posts SET is_active=:is_active WHERE id=:id",
Delete: "DELETE FROM posts WHERE id=:id",
SoftDelete: "UPDATE posts SET deleted_at=CURRENT_TIMESTAMP() WHERE id=:id",
},
Queries: map[string]string{
"SelectUsersByFirstName": "SELECT * FROM users WHERE first_name = :first_name",
},
}
```##### Default Queries
```go
res, err := q.SelectOne(CxArgs{"id": 154, "post_title": "Hello World"})
if err != nil {
panic(err)
}
fmt.Println(res.postId)
```##### Custom Queries
```go
_, err := q.RawQuery(q.Queries["SelectUsersByFirstName"], CxArgs{"first_name": "John"})
if err != nil {
return
}
```### Roadmap
1. Integrate Migrations into Godex (a feature which exists within Sphire's Codex utility)
2. Unit tests
3. Github Actions