knadh / localStorageDB

A simple database layer for localStorage and sessionStorage for creating structured data in the form of databases and tables
http://nadh.in/code/localstoragedb
814 stars 128 forks source link

How can I query all items? #1

Closed dmarko484 closed 13 years ago

dmarko484 commented 13 years ago

At the first, very nice project, clean API, really, really nice to work with.

My question: How to query all items in table, I mean how to use 'query' function with no condition specified? I 'm just currently using this: lib.query("books",{return true}) ... not sure if there is some easiest way ... something like lib.query("books") ???

knadh commented 13 years ago

This works. ID is the internal auto-incremented numerical id, and every record has an ID > 0.

lib.query("books", function(row) {
    return row.ID > 0 ? true : false;
})

However, I realise that this is kind of lame. Will submit a patch in a bit that'll let you do lib.query("books");

knadh commented 13 years ago

The issue has been addressed - knadh/localStorageDB@b80625a05f8eb5b41185d47f4063982b50b27a18

You can now do lib.query("books") to select all rows.

dmarko484 commented 13 years ago

Thank you for a such a prompt response ...