Skip to content

Instantly share code, notes, and snippets.

@gszr
Last active May 21, 2024 19:15
Show Gist options
  • Save gszr/bcf525dd80ca216e183672984b95c6d0 to your computer and use it in GitHub Desktop.
Save gszr/bcf525dd80ca216e183672984b95c6d0 to your computer and use it in GitHub Desktop.
local inspect = require "inspect"
require("kong.globalpatches")({
cli = true,
})
local conf_loader = require "kong.conf_loader"
local DB = require "kong.db"
local conf = assert(conf_loader(TEST_CONF_PATH))
conf.database = "postgres"
local db = assert(DB.new(conf))
assert(db:init_connector())
local ok, err
consumer, err = db.consumers:insert({
username = "c1",
})
print("res = ", inspect(consumer))
print("err = ", inspect(err))
ok, err = db.consumers:select({
id = consumer.id,
})
print("res = ", inspect(ok))
print("err = ", inspect(err))
ok, err = db.consumers:delete({
id = consumer.id,
})
print("res = ", inspect(ok))
print("err = ", inspect(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment