Skip to content

amakawa/ohm.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ohm.lua

A port of the popular ohm library to Lua.

example

-- define this in models/user.lua
local ohm = require("ohm")

return ohm.model("User", {
    attributes = {
        "lname",
        "fname",
        "email"
    },

    indices = {
        "full_name"
    },

    uniques = {
        "email"
    }
})

-- using it: (e.g. in app.lua)

local user = require("models/user")
local resp = require("resp")

local attributes = {
    email = "john@example.org",
    fname = "John",
    lname = "Doe",
    full_name = "John Doe",
}

local db = resp.new("localhost", 6379)
local id = assert(user:save(db, attributes))

assert("1" == id)

license

MIT

About

lightweight object mapping for redis

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages