This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

filter table data NON DB
#1
It is possible to filter id atts in a non-DB table

if I have a table from which I take data with

PowTable = storage.get ('MyPowerLog', {})

can I make a select on the data?

Thanks so much
Reply
#2
You need to filter the table manually in a "for" loop. In this example the result table is populated will all items where the time field is not older than 1 day (86400 seconds).
Code:
items = storage.get('MyPowerLog', {})
result = {}

now = os.time()
mintime = now - 86400

for _, item in ipairs(items) do
  if item.time >= mintime then
    table.insert(result, item)
  end
end

log(result)
Reply


Forum Jump: