JSON querying library. This library is written for Node JS in order to query the JSON files.
I was working on Node script that would automatically test the ping and network connection speed and instead of loading the results in SQL or any other conventional database I decided to go with the JSON. JSON is the JavaScript Object Notation. It is very similar to the structures in C/C++ but the main point of JSON is the fact that JavaScript natively parses JSON. For making the life easier JSQL works with the array of JSON's stored in the file for automatic indexing. Another pro of JSON is its native support by all webapps written in JavaScript.
JSQL loads an array of JSON's from the file you want to use and then using the written library you can query the JSON file. JSON array is a table and array item is a tuple.
- constructor(filename,name) - constructs a table from given file
- rename(name) - renames the table
- checkSchema() - checks if the schema is consistent throughout the table
- printSchema() - prints the schema of table on the console
- print() - prints whole table on the console
- toString() - returns table as a formatted string
- insert(row) - inserts correctly formatted object row into the table and table's json file
- toHTML(path) - creates file %name.html for visualizing table
- simpleSearch(column, value) - essentially same as
SELECT * FROM %name WHERE %column = %value
- simpleSearchWithAttributes(column, value, attribute) - essentialy same as
SELECT %sttribute FROM %name WHERE %column = %value
Both search functions return array of results
*duplicateSearch() - returns specifically formatted array of all duplicates in the table
Duplicate Array is formatted in this way
{ item: %row, originalIndex: %rowIndex, duplicateIndex: %{aray of row duplicate indeces} }
- Adding user prompt to the script
- Adding server capabilities
JSQL is an npm package so just download it and run
npm install
and then look at files in Example directory for testing. You can also run npm test to test basic capabilities.