I’m trying to write some Lua code to find the keyauth_credentials key for a given Consumer. Looking at the source file kong/db/dao/init.lua, it appears that each field in a Kong table should be directly searchable with a :select_by_ method. For the keyauth_credentials table, it has an indexed field consumer_id:
postgres = {
up = [[
CREATE TABLE IF NOT EXISTS "keyauth_credentials" (
"id" UUID PRIMARY KEY,
"created_at" TIMESTAMP WITH TIME ZONE DEFAULT (CURRENT_TIMESTAMP(0) AT TIME ZONE 'UTC'),
"consumer_id" UUID REFERENCES "consumers" ("id") ON DELETE CASCADE,
"key" TEXT UNIQUE
);
DO $$
BEGIN
CREATE INDEX IF NOT EXISTS "keyauth_credentials_consumer_id_idx" ON "keyauth_credentials" ("consumer_id");
EXCEPTION WHEN UNDEFINED_COLUMN THEN
-- Do nothing, accept existing state
END$$;
]],
},
So I assumed there would be a corresponding select_by_consumer_id method as there’s a select_by_key() one. However, it appears that isn’t the case:
attempt to call method 'select_by_consumer_id' (a nil value),
How does one tell whether a given field in a Kong table has a corresponding select_by_* method?