Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tyrant still fubar

  • Loading branch information...
commit f6beb47b8e227620c08ad369db0ae70118b8aa36 1 parent 0c086c3
@comotion authored
Showing with 15 additions and 22 deletions.
  1. +10 −7 web/lib/tracks.lua
  2. +5 −15 web/lib/tyrant.lua
View
17 web/lib/tracks.lua
@@ -42,7 +42,7 @@ function tracks:add(cols)
cols.station = cols.station or default_station
print("adding ".. u.dump(cols))
if cols.md5 then
- id = tracks:ssearch({md5=md5})
+ id = db:ssearch(_t,{md5=md5})
if #id ~= 0 then
print("found id "..u.dump(id))
return id
@@ -61,9 +61,9 @@ function tracks:search(query, qf, qop, order)
local result, size
if type(query) == "table" then
- result,size = db:ssearch(query, qop, order)
+ result,size = db:ssearch(_t, query, qop, order)
else
- result,size = tracks:gsearch(query, qf, order)
+ result,size = db:gsearch(_t, query, qf, order)
end
return tracks.fill(result),size
end
@@ -93,20 +93,23 @@ function tracks.fill(result)
end
function tracks:dump()
- trk:iterinit()
+return nil
+--[[
+ db:iterinit()
local key, value, accu
accu = {}
while true do
- key = trk:iternext()
+ key = db:iternext()
if not key then break end
- value = trk:get(key)
+ value = db:get(key)
table.insert(accu,value)
end
return u.dump(accu)
+ --]]
end
function tracks:get(pkey)
- local track = trk:get(pkey)
+ local track = db:get(_t,pkey)
track.id = pkey
return track
end
View
20 web/lib/tyrant.lua
@@ -44,7 +44,7 @@ local op = {
noindex = "NOIDX",
}
-local sort = {
+tyrant.sort = {
lexic = "STRASC",
reverse = "STRDESC",
increasing= "NUMASC",
@@ -59,7 +59,7 @@ function tyrant:init(name)
db:open()
end
-- XXX pass "handle" back to client
- return self
+ return db,tbl
end
-- create an entry
@@ -67,13 +67,14 @@ function tyrant:add(name, cols)
cols._type = name
cols.added = cols.added or os.time()
local id = tbl:genuid()
+ print("ADDING!"..u.dump(cols))
return tbl:put(id, cols)
end
-- find entries of given _type=name
function tyrant:search(name, query, qop, order)
local q = tyr.query.new()
- q:addcond('_type', op.equals, name)
+ q:addcond('_type', op.equal, name)
for k,v in pairs(query) do
q:addcond(k, qop, v)
end
@@ -85,6 +86,7 @@ end
function tyrant:ssearch(name, query, qop, order)
local query = query or {_type = name, station=default_station}
local qop = qop or op.equal
+ print("qop is ".. u.dump(qop))
-- q:setlimit(limit, skip) -- we need the size so there is no use
local res = tyrant:search(name, query, qop, order)
return res, #res
@@ -125,18 +127,6 @@ end
function tyrant:dump(name)
--iterate over the whole db, or _type = name
end
-function tyrant:get(pkey)
--- get primary key
-end
-function tyrnat:put(pkey, cols)
--- put stuff
-end
-function tyrant:update(pkey,cols)
--- merge stuff in to the database
-end
-function tyrant:search(db, query, qop, order)
--- search db for strings
-end
-- search for query in all queryfields
-- honour queries like "foo bar tag:value"
Please sign in to comment.
Something went wrong with that request. Please try again.