Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resty/sql
.gitignore
LICENSE
README.md
dist.ini

README.md

lua-resty-sql

Get sql statement from lua object.

Requirements

Nothing.

Synopsis

local Sql = require"resty.sql.postgresql"

local Profile = {
    table_name = 'profile',
    fields = {
        {name='id'},
        {name='sex'},
    },
}

local foreign_key = {name='p', reference=Profile}
local User = {
    table_name = 'user',
    fields = {
        {name='id'},
        foreign_key,
        {name='name'},
    },
    foreign_keys = {
        p = foreign_key,
    },
}

local sql = Sql:class{model=User}

-- now use sql in your controllers
local s1, err = sql:new{}:where{p__sex='male',name__startswith='k'}:statement()
if err then
    return err
end

local s2, err = sql:new{}:update{name='kate'}:where{id=1}:statement()
if err then
    return err
end


You can’t perform that action at this time.