feat(clients): add nim-allographer client with BaraDB driver support
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
- Pure Nim wire protocol client (async + sync, no C FFI) - Query Builder: fluent API, SQL generator, execution, transactions - Schema Builder: create/alter/drop tables, column operations - Connection pool with aging and timeout handling - ORM integration via compile-time DB_BARADB switch - Tests: test_open, test_query - Documentation: README.md, PLAN_BARADB.md
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import std/asyncdispatch
|
||||
import std/strformat
|
||||
import std/json
|
||||
import ../src/allographer/query_builder
|
||||
import ../src/allographer/schema_builder
|
||||
from ./connections import rdb
|
||||
|
||||
|
||||
rdb.create([
|
||||
table("auth",[
|
||||
Column.increments("id"),
|
||||
Column.string("name")
|
||||
]),
|
||||
table("users",[
|
||||
Column.increments("user_id"),
|
||||
Column.string("name").nullable(),
|
||||
Column.string("email").nullable(),
|
||||
Column.string("password").nullable(),
|
||||
Column.string("address").nullable(),
|
||||
Column.date("birth_date").nullable(),
|
||||
Column.foreign("auth_id").reference("id").onTable("auth").onDelete(SET_NULL)
|
||||
])
|
||||
])
|
||||
|
||||
# シーダー
|
||||
seeder rdb, "auth":
|
||||
rdb.table("auth").insert(@[
|
||||
%*{"name": "admin"},
|
||||
%*{"name": "user"}
|
||||
])
|
||||
.waitFor
|
||||
|
||||
let total = 20
|
||||
var insertData: seq[JsonNode]
|
||||
for i in 1..total:
|
||||
let authId = if i mod 2 == 0: 1 else: 2
|
||||
insertData.add(
|
||||
%*{
|
||||
"name": &"user{i}",
|
||||
"email": &"user{i}@gmail.com",
|
||||
"password": &"password{i}",
|
||||
"auth_id": authId
|
||||
}
|
||||
)
|
||||
|
||||
rdb.table("users").insert(insertData).waitFor()
|
||||
echo rdb.table("users").get().waitFor()
|
||||
|
||||
echo rdb.table("users").find(2, key="user_id").waitFor()
|
||||
echo rdb.table("auth").find(1).waitFor()
|
||||
|
||||
rdb.table("users").delete(2, key="user_id").waitFor()
|
||||
rdb.table("auth").delete(2).waitFor()
|
||||
echo rdb.table("users").limit(3).get().waitFor()
|
||||
echo rdb.table("auth").limit(3).get().waitFor()
|
||||
Reference in New Issue
Block a user