Closed a904guy closed 10 years ago
I have an addition sorting function (iterates through select results) completed as well.
Fair enough, but the existing regex doesn't allow numeric, a integer like murmurhash hash wasn't being allowed as a table name because it has no match function. Hence casting into String first.
(Removed CRC32 (alphanumeric) comment, was using murmurhash)
@a904guy, can you post a couple examples of this please? Thanks.
@knadh, http://jsfiddle.net/RaL7b/1/
@knadh, Using my pull commit: http://jsfiddle.net/V7egC/
I know its not perfect, needs validation against NaN,undefined,null, etc
I see what you mean now. Casting all inputs to string and then doing the regex should cover all cases then. Like you said, the non-regex route leaves a bunch of a exceptions to be dealt with. Will commit with casting.
Excellent. Thank you.
I have a small question, why is it that you don't want spaces in field names? Just so it makes it appear more like a database, or is a programmatic reason?
I only ask because with the storage being JSON, spaces in database,tables,field names shouldn't matter. So for a dynamic backend data system being used to store data with this, you have to pre-filter your data in/out if they contain spaces.
In example: I was using this make a dynamic table rendering for an analytical system and the table fields (thead:tr:th) contained spaces occasionally, which was my reason for needing it.
Not allowing spaces in db/table/field names is for the sake of convention, readability, and consistency.
As an example, the way it is right now, one can do row.field_name
without second thoughts. If spaces and other special characters were allowed, then it'd have to be row["field name"]
.
https://github.com/knadh/localStorageDB/commit/6f353d15c18c639b51672b2d15214478d43fdc90 adds string casting to name validation
Added start to query function for easy pagination. ( limit, start )
In Example: limit = per_page. start = (page - 1) * per_page
Also added tableKeys function to return the fields of a table.
Updated README with documentation as well.