all repos — litestore @ caf24961365f9735cc633dda6663be8816281037

A minimalist nosql document store.

src/admin/md/api_stores.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
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
### stores (LiteStore Stores)

> %note%
> API v7 Required
> 
> This resource has been introduced in version 7 of the LiteStore API.

As of version 1.9.0, it is possible for a single LiteStore process to manage multiple data store files. These additional stores can be accessed but also added or removed at run time using this resource.

#### OPTIONS stores

Returns the allowed HTTP verbs for this resource.

##### Example

```
$ curl -i -X OPTIONS http://127.0.0.1:9500/stores
HTTP/1.1 200 OK
server: LiteStore/1.9.0
access-control-allow-origin: http://localhost:9500
access-control-allow-headers: Content-Type
allow: GET,OPTIONS
access-control-allow-methods: GET,OPTIONS
content-length: 0
```

#### OPTIONS stores/:id

Returns the allowed HTTP verbs for this resource.

##### Example

```
$ curl -i -X OPTIONS http://127.0.0.1:9500/stores/test1
HTTP/1.1 200 OK
server: LiteStore/1.9.0
access-control-allow-origin: http://localhost:9500
access-control-allow-headers: Content-Type
allow: GET,OPTIONS,PUT,DELETE
access-control-allow-methods: GET,OPTIONS,PUT,DELETE
Content-Length: 0
```

#### GET indexes

Retrieves information on all available stores (file name and configuration).

##### Example

```
$ curl -i http://localhost:9500/stores
HTTP/1.1 200 OK
content-type: application/json
access-control-allow-origin: http://127.0.0.1:9500
access-control-allow-headers: Authorization, Content-Type
vary: Origin
server: LiteStore/1.9.0
Content-Length: 2346

{
  "total": 4,
  "execution_time": 0.0,
  "results": [
    {
      "id": "test1",
      "file": "test1.db",
      "config": null
    },
    {
      "id": "test2",
      "file": "test2.db",
      "config": null
    },
    {
      "id": "test3",
      "file": "test3.db",
      "config": null
    },
    {
      "id": "master",
      "file": "data.db",
      "config": {
        "settings": {
          "log": "debug",
          "port": 9200
        },
        "stores": {
          "test1": {
            "file": "test1.db",
            "config": null
          },
          "test2": {
            "file": "test2.db",
            "config": null
          },
          "test3": {
            "file": "test3.db",
            "config": null
          }
        },
        "resources": {
          "/docs/vehicles/*": {
            "GET": {
              "middleware": [
                "validate",
                "log"
              ]
            },
            "HEAD": {
              "middleware": [
                "validate",
                "log"
              ]
            },
            "POST": {
              "allowed": false
            },
            "PATCH": {
              "auth": [
                "admin:vehicles"
              ],
              "middleware": [
                "validate",
                "log"
              ]
            },
            "PUT": {
              "auth": [
                "admin:vehicles"
              ],
              "middleware": [
                "validate",
                "log"
              ]
            },
            "DELETE": {
              "auth": [
                "admin:vehicles"
              ],
              "middleware": [
                "validate",
                "log"
              ]
            }
          },
          "/docs/logs/*": {
            "GET": {
              "auth": [
                "admin:server"
              ]
            },
            "POST": {
              "allowed": false
            },
            "PUT": {
              "allowed": false
            },
            "PATCH": {
              "allowed": false
            },
            "DELETE": {
              "allowed": false
            }
          }
        },
        "signature": "\n-----BEGIN CERTIFICATE-----\n<certificate text goes here>\n-----END CERTIFICATE-----\n"
      }
    }
  ]
}
```

#### GET stores/:id

Retrieves information on the specified store.

##### Example

```
HTTP/1.1 200 OK
content-type: application/json
access-control-allow-origin: http://127.0.0.1:9500
access-control-allow-headers: Authorization, Content-Type
vary: Origin
server: LiteStore/1.9.0
Content-Length: 46

{"id":"test1","file":"test1.db","config":null}
```

#### PUT stores/:id

Adds a new stores with the specified ID. If a file called **\<id\>.db** does not exist already, it will be created in the current working directory and initialized as a LiteStore store.

Note that:
* Index IDs can only contain letters, numbers, and underscores.
* The body must be present and contain the store configuration (or **null**).

> %warning%
> No updates
>
> It is not possible to update an existing store. Remove it and re-add it instead.


##### Example

```
curl -i -X PUT -d "null" "http://127.0.0.1:9500/stores/test3" --header "Content-Type:application/json"
HTTP/1.1 201 Created
content-type: application/json
access-control-allow-origin: http://127.0.0.1:9500
access-control-allow-headers: Authorization, Content-Type
vary: Origin
server: LiteStore/1.9.0
Content-Length: 46

{"id":"test3","file":"test3.db","config":null}
```

#### DELETE stores/:id

Removes the specified store. Although it will no longer be accessible via LiteStore, the corresponding file will *not* be deleted from the filesystem.

##### Example

```
$ curl -i -X DELETE "http://127.0.0.1:9200/stores/test3"
HTTP/1.1 204 No Content
vary: Origin
access-control-allow-origin: http://127.0.0.1:9200
access-control-allow-headers: Authorization, Content-Type
content-length: 0
server: LiteStore/1.9.0
Content-Length: 0
```

#### \* stores/:id/\*

Forward the request to the specified store. Essentially, the path fragment after the store ID will be forwarded as a standard request to the specified store.

##### Examples

Retrieve all tags from store **vehicles**:
```
$ curl -i http://localhost:9500/stores/vehicles/tags/
```


Delete the document with ID **AA457DB** from store **vehicles**:

```
$ curl -i -X DELETE "http://127.0.0.1:9200/stores/vehicles/docs/AA457DB"
```