all repos — litestore @ 6ae6131855fd32d797d8033783ec3df04dbf73c6

A minimalist nosql document store.

Updated docs; minor fixes.
h3rald h3rald@h3rald.com
Sat, 05 May 2018 13:27:17 +0200
commit

6ae6131855fd32d797d8033783ec3df04dbf73c6

parent

cd4b3f1a419f9900d51beaaf666ab338e3dfe98f

6 files changed, 35 insertions(+), 11 deletions(-)

jump to
M admin/md/api_docs.mdadmin/md/api_docs.md

@@ -459,7 +459,7 @@

{"id": "test.json", "data": {"test": true}, "created": "2015-09-20T09:06:25Z", "modified": null, "tags": ["$type:application", "$subtype:json", "$format:text", "test1", "test2", "test3"]} ``` -##### Example: Patching Daya +##### Example: Patching Data Given the following document:
M admin/md/overview.mdadmin/md/overview.md

@@ -19,30 +19,38 @@ ### Key Features

Despite being fairly small and self-contained, LiteStore comes with many useful features that are essential for many use cases. -#### [](class:fa-file-text-o) Multi-format Documents +#### Multi-format Documents LiteStore can be used to store documents in virtually any format, as long as you specify an appropriate content type for them. Textual documents are stored as-is, while binary documents are base64-encoded (not the best thing in the world, but definitely the easiest and most portal option). -#### [](class:fa-tags) Document Tagging +#### Document Tagging You can add custom tags to documents to easily categorize them and retrieve them. Some system tags are also added automatically to identify the document content type, format and collection. -#### [](class:fa-tasks) Enhanced Querying of JSON documents +#### Enhanced Querying of JSON documents By leveraging the [SQLite JSON1 extension](https://www.sqlite.org/json1.html) and implementing custom query string parsing, LiteStore provides enhanced filtering, ordering, and custom field selection of JSON documents. -#### [](class:fa-search) Full-text Search +#### Full-text Search By leveraging [SQLite FTS4 extension](http://www.sqlite.org/fts3.html) and implementing an enhanced algorithm for result rankings, LiteStore provides full-text search for all textual documents out-of-the-box. -#### [](class:fa-gears) RESTful HTTP API +#### RESTful HTTP API Every operation can be performed on the data store using a simple but powerful RESTful HTTP API, perfect for client-side, single-page applications. -#### [](class:fa-exchange) Directory Bulk Import/Export +#### Nim API + +If you want, you can use LiteStore as a [Nim](https://nim-lang.org) library and perform data store operations from your own Nim program. + +#### Command-line API + +Every operation can also be performed from command line, using the [litestore execute](class:cmd) command. + +#### Directory Bulk Import/Export To make serving a single-page application _from LiteStore_ even easier and faster, you can automatically import (and export) the contents of a directory recursively. -#### [](class:fa-cloud-upload) Directory Mounting and Mirroring +#### Directory Mounting and Mirroring After importing the contents of a directory into a LiteStore data store, you can _mount it_ on LiteStore and mirror all data store changes to the filesystem. Incidentally, that's how most of the LiteStore Admin test app was built [](class:fa-smile-o).
M admin/md/usage.mdadmin/md/usage.md

@@ -8,6 +8,7 @@ #### Commands

* **run** — Start LiteStore server (default if no command specified). * **delete** — Delete a previously-imported specified directory (requires -d). +* **execute** — Execute an operation on data stored in the datastore (requires -o, -u, and in certain cases -f or -b and -t). * **import** — Import the specified directory into the datastore (requires -d). * **export** — Export the previously-imported specified directory to the current directory (requires -d). * **optimize** — Optimize search indexes.

@@ -16,13 +17,18 @@

#### Options * **-a**, **-\-address** — Specify server address (default: 127.0.0.1). +* **-b**, **--body** — Specify a string containing input data for an operation to be executed. * **-d**, **-\-directory** — Specify a directory to serve, import, export, delete, or mount. +* **-f**, **--file** — Specify a file containing input data for an operation to be executed. * **-h**, **-\-help** — Display program usage. * **-l**, **-\-log** — Specify the log level: debug, info, warn, error, none (default: info) * **-m**, **-\-mount** — Mirror database changes to the specified directory on the filesystem. +* **-o**, **--operation** — Specify an operation to execute via the execute command: get, put, delete, patch, post, head, options. * **-p**, **-\-port** —Specify server port number (default: 9500). * **-r**, **-\-readonly** — Allow only data retrieval operations. * **-s**, **-\-store** — Specify a datastore file (default: data.db) +* **-t**, **--type** — Specify a content type for the body an operation to be executed via the execute command. +* **-u**, **--uri** — Specify an uri to execute an operation through the execute command. * **-v**, **-\-version** — Display the program version. ### Examples

@@ -75,3 +81,13 @@

* optimize search index: [litestore optimize](class:cmd) + +#### Executing operations + +* Retrieve all documents tagged with `$subtype:json`: + + [litestore execute -o:get -u:docs?tags=$subtype:json](class:cmd) + +* Add a new document from a JSON file: + + [litestore execute -o:put -u:docs/test-doc -f:test.json -t:application/json](class:cmd)
M build_guidebuild_guide

@@ -21,7 +21,7 @@ for page in ${pages[@]}

do (cat "${page}"; printf "\n\n") >> LiteStore_UserGuide.md done -hastyscribe --field/version:1.3.1 LiteStore_UserGuide.md +hastyscribe --field/version:1.4.0 LiteStore_UserGuide.md rm LiteStore_UserGuide.md mv LiteStore_UserGuide.htm .. cd ..
M lib/cli.nimlib/cli.nim

@@ -43,7 +43,7 @@ Options:

-a, --address Specify server address (default: 127.0.0.1). -b, --body Specify a string containing input data for an operation to be executed. -d, --directory Specify a directory to serve, import, export, delete, or mount. - -b, --body Specify a file containing input data for an operation to be executed. + -f, --file Specify a file containing input data for an operation to be executed. -h, --help Display this message. -l, --log Specify the log level: debug, info, warn, error, none (default: info) -m, --mount Mirror database changes to the specified directory on the filesystem.
M test/http_api.nimtest/http_api.nim

@@ -34,7 +34,7 @@ proc info(prop: string): JsonNode =

return jget("info").body.parseJson[prop] proc total(resp: Response): BiggestInt = - return resp.body.parseJson["total"].getNum + return resp.body.parseJson["total"].getInt setup: var count = 0