all repos — litestore @ 163338ac63b127ea484c7e8de7714b3fc5f9962a

A minimalist nosql document store.

src/admin/md/usage.md

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
## Usage

### Command Line Syntax

[litestore](class:kwd) **[** _command_ **]** **[** _option1_, _option2_, ... **]**

#### 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.
* **vacuum** — Vacuum datastore.

#### Options

* **-a**, **-\-address** — Specify server address (default: 127.0.0.1).
* **--auth** — Specify an authorization configuration file.
* **-b**, **--body** — Specify a string containing input data for an operation to be executed.
* **-c**, **--config** — Specify a configuration file.
* **-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)
* **--system**  — Set the system flag for import, export, and delete operations
* **--importTags**  — During import read tags from '_tags' file and apply them to imported documents from the same directory.
* **-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.
* **-w**, **--middleware** — Specify a path to a folder containing middleware definitions

### Examples

#### Starting the HTTP Server

* with default settings:
  
  [litestore](class:cmd)

* loading configuration from a configuration file called **config.json**:

  [litestore -c:config.json](class:cmd)
  
* loading middleware definition files stored in a directory called **myMiddleware**:

  [litestore -w:myMiddleware](class:cmd)

* with custom port (**9700**) and address (**0.0.0.0**):
 
  [litestore -p:9700 -a:0.0.0.0](class:cmd)

* in read-only mode with logging level set to **debug**:

  [litestore -r -l:debug](class:cmd)
  
* serving the contents of a directory called **admin**:

  [litestore -d:admin](class:cmd)

* mouting a directory called **admin** (changes will be mirrored to filesystem, directory contents will be served):

  [litestore -d:admin -m](class:cmd)

#### Importing a directory

Import a directory called **admin**:

[litestore import -d:admin](class:cmd)

#### Importing system documents from a directory

Import all documents stored in a directory called **system** as system documents:

[litestore import -d:system --system](class:cmd)

Import all documents stored in a directory called **media** (including subdirectories):
```
+ media
  + cars
  | + _tags
  | + Lamborgini.jpg
  | + VW.jpg
  | ` BMW.jpg
  + planes
  | + _tags
  | + 767.jpg
  | + F-16.jpg
  | ` B-1.jpg
  ` trains
    + TGV.jpg
    ` Eurostar.jpg
```   

[litestore import -d:media --importTags](class:cmd)

Every **_tags** file contains a list of tags, one per line, which are applied to all imported documents from the same directory. In the example above all cars and planes images will be tagged on import. The trains images, not as there is not **_tags** file in the **trains** directory.

The individual **_tags** files are also imported. When the **--importTags** option is not set the **_tags** files are ignored and not imported.

#### Exporting a directory

Export all documents tagged with **$dir:admin** to a local directory called **admin**:

[litestore export -d:admin](class:cmd)

#### Deleting documents within a directory

Delete all documents tagged with **$dir:admin**:

[litestore delete -d:admin](class:cmd)

#### Performing maintenance operations

* vacuum SQlite database:

  [litestore vacuum](class:cmd)

* 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)