Your custom plugins can interact with Kong Gateway entities in the PostgreSQL data store through classes we refer to as Data Access Objects (DAOs).
All entities in Kong Gateway, including custom entities are represented by:
- A schema that describes which table the entity relates to in the data store, constraints on its fields such as foreign keys, non-null constraints etc. For custom entities, this is defined in daos.lua.
- An instance of the
DAO
class mapping to the database currently in use. This class’s methods consume the schema and expose methods to insert, update, select, and delete entities of that type.
Both core entities from Kong Gateway and custom entities from plugins are
available through kong.db.{entity-name}
. For example:
local services = kong.db.services
local routes = kong.db.routes
local consumers = kong.db.consumers
local plugins = kong.db.plugins