修改测试例子

This commit is contained in:
wanglei 2025-10-14 17:16:16 +08:00
parent 4c18c0bdac
commit 2801aa9647
3 changed files with 9 additions and 7 deletions

View File

@ -7,7 +7,7 @@ events {
}
http {
lua_package_path 'src/?/?.lua;src/?.lua;src/share/?/?.lua;src/share/?.lua;/home/frankly/work/AuthPlatform/src/share/lib/?/?.lub;/home/frankly/work/AuthPlatform/src/share/lib/ngx-oauth/?.lua;;';
lua_package_path 'src/?/?.lua;src/?.lua;src/share/?/?.lua;src/share/?.lua;/home/frankly/work/AuthPlatform/src/share/lib/?/?.lub;/home/frankly/work/AuthPlatform/src/share/lib/ngx-oauth/?.lua;/home/frankly/work/AuthPlatform/src/share/?/?.lub;/home/frankly/work/AuthPlatform/src/share/?.lua;;';
lua_package_cpath 'src/share/lib/?.so;;';
# Path of the file with trusted CA certificates.

View File

@ -47,6 +47,8 @@ DB = {
password = DB.password or nil
}
print(DB)
local sql, _connect
-- Get database by settings

View File

@ -4,10 +4,10 @@ DB = {
DEBUG = true,
new = true,
backtrace = true,
name = "AuthDB",
name = "postgres",
type = "postgresql",
username = "postgresql",
password = "Admin123",
username = "postgres",
password = "1qaz2wsx",
host = "127.0.0.1",
port = 5432
}
@ -37,15 +37,15 @@ local user = User({
})
user:save()
print("User " .. user.username .. " has id " .. user.id)
ngx.say("User " .. user.username .. " has id " .. user.id)
-- User Bob Smith has id 1
----------------------------- GET DATA --------------------------------
local first_user = User.get:first()
print("First user name is: " .. first_user.username)
ngx.say("First user name is: " .. first_user.username)
-- First user name is: First user
local users = User.get:all()
print("We get " .. users:count() .. " users")
ngx.say("We get " .. users:count() .. " users")
-- We get 5 users