|
14 | 14 | - [GET /dbs](#get-dbs)
|
15 | 15 | - [GET /db/:dbname](#get-dbdbname)
|
16 | 16 | - [GET /db/:dbname/value](#get-dbdbnamevalue)
|
17 |
| - - [GET /db/:dbname/query](#get-dbdbnamequery) |
18 |
| - - [Modulus Query](#modulus-query) |
19 |
| - - [Range Query](#range-query) |
20 | 17 | - [GET /db/:dbname/:item](#get-dbdbnameitem)
|
21 | 18 | - [GET /db/:dbname/iterator](#get-dbdbnameiterator)
|
22 | 19 | - [GET /db/:dbname/index](#get-dbdbnameindex)
|
23 | 20 | - [GET /identity](#get-identity)
|
24 | 21 | - [POST /db/:dbname](#post-dbdbname)
|
| 22 | + - [POST /db/:dbname/query](#post-dbdbnamequery) |
| 23 | + - [Modulus Query](#modulus-query) |
| 24 | + - [Range Query](#range-query) |
25 | 25 | - [POST|PUT /db/:dbname/add](#post-put-dbdbnameadd)
|
26 | 26 | - [POST|PUT /db/:dbname/put](#post-put-dbdbnameput)
|
27 | 27 | - [POST|PUT /db/:dbname/inc](#post-put-dbdbnameinc)
|
28 | 28 | - [POST|PUT /db/:dbname/inc/:val](#post-put-dbdbnameincval)
|
29 |
| - - [POST|PUT /db/:dbname/access/write](#post-put-dbdbnameaccesswrite) |
| 29 | + - [POST|PUT /db/:dbname/access/writ](#post-put-dbdbnameaccesswrite) |
30 | 30 | - [DELETE /db/:dbname](#delete-dbdbname)
|
31 | 31 | - [DELETE /db/:dbname/:item](#delete-dbdbnameitem)
|
32 | 32 | - [Contribute](#contribute)
|
@@ -122,76 +122,6 @@ curl -X GET http://localhost:3000/db/counter/value
|
122 | 122 | 1
|
123 | 123 | ```
|
124 | 124 |
|
125 |
| -### GET /db/:dbname/query |
126 |
| - |
127 |
| -Queries the database :dbname. |
128 |
| - |
129 |
| -Returns a list of found items as a JSON array. |
130 |
| - |
131 |
| -```shell |
132 |
| -curl http://localhost:3000/db/docstore/query -X GET -H "Content-Type: application/json" --data '{"values":[]}' |
133 |
| -``` |
134 |
| - |
135 |
| -```json |
136 |
| -[{"project":"OrbitDB","site":"https://github.com/orbitdb/orbit-db","likes":200},{"project":"IPFS","site":"https://ipfs.io","likes":400}] |
137 |
| -``` |
138 |
| - |
139 |
| -To query a subset of data, a condition can be specified. For example, to |
140 |
| -retrieve only those entries which have a total number of likes above 300: |
141 |
| - |
142 |
| -```shell |
143 |
| -curl http://localhost:3000/db/docstore/query -X GET -H "Content-Type: application/json" --data '{"propname":"likes","comp":">","values":[300]}' |
144 |
| -``` |
145 |
| - |
146 |
| -```json |
147 |
| -[{"project":"IPFS","site":"https://ipfs.io","likes":400}] |
148 |
| -``` |
149 |
| - |
150 |
| -Available operator short-codes are: |
151 |
| - |
152 |
| -```eq``` propname equals value. Equivalent to "==" |
153 |
| - |
154 |
| -```ne``` propname is not equals to value. Equivalent to "!=" |
155 |
| - |
156 |
| -```gt``` propname is greater than value. Equivalent to ">" |
157 |
| - |
158 |
| -```lt``` propname is less than value. Equivalent to "<" |
159 |
| - |
160 |
| -```gte``` propname is greater than or equal to value. Equivalent to ">=" |
161 |
| - |
162 |
| -```lte``` propname is less than or equal to value. Equivalent to "<=" |
163 |
| - |
164 |
| -```mod``` Perform a modulus calculation on propname using value. Equivalent to "%" |
165 |
| - |
166 |
| -```range``` Perform a range query, comparing propname to min and max. |
167 |
| - |
168 |
| -```all``` Fetch all records for field propname. Equivalent to "*" |
169 |
| - |
170 |
| -#### Modulus Query |
171 |
| - |
172 |
| -When using a modulus query, you must supply the divisor and the remainder. For example, to obtain all likes which are multiples of 100, you would specify a divisor 100 and a remainder 0: |
173 |
| - |
174 |
| -```shell |
175 |
| -curl -X GET http://localhost:3000/db/docstore/query -H "Content-Type:application/json" --data '{"propname":"likes", "comp":"mod", "values":[100,0]}' |
176 |
| -``` |
177 |
| - |
178 |
| -```json |
179 |
| -[{"site":"https://ipfs.io","likes":400,"project":"IPFS"},{"site":"https://github.com/orbitdb/orbit-db","likes":200,"project":"OrbitDB"}] |
180 |
| -``` |
181 |
| - |
182 |
| -#### Range Query |
183 |
| - |
184 |
| -When specifying a range query, you must supply the min and max |
185 |
| -values. For example, to obtain all likes greater than 250 but less than 1000 the min and max must be supplied: |
186 |
| - |
187 |
| -```shell |
188 |
| -curl -X GET http://localhost:3000/db/docstore/query -H "Content-Type:application/json" --data '{"propname":"likes", "comp":"range", "values":[250,1000]}' |
189 |
| -``` |
190 |
| - |
191 |
| -```json |
192 |
| -[{"site":"https://ipfs.io","likes":400,"project":"IPFS"},{"site":"https://github.com/orbitdb/orbit-db","likes":200,"project":"OrbitDB"}] |
193 |
| -``` |
194 |
| - |
195 | 125 | ### GET /db/:dbname/:item
|
196 | 126 |
|
197 | 127 | Gets a record identified by :item from the database :dbname.
|
@@ -336,6 +266,76 @@ overwrite flag:
|
336 | 266 | curl http://localhost:3000/db/docstore -d "create=true" -d "type=docstore" -d "overwrite=true"
|
337 | 267 | ```
|
338 | 268 |
|
| 269 | +### POST /db/:dbname/query |
| 270 | + |
| 271 | +Queries the database :dbname. |
| 272 | + |
| 273 | +Returns a list of found items as a JSON array. |
| 274 | + |
| 275 | +```shell |
| 276 | +curl http://localhost:3000/db/docstore/query -X GET -H "Content-Type: application/json" --data '{"values":[]}' |
| 277 | +``` |
| 278 | + |
| 279 | +```json |
| 280 | +[{"project":"OrbitDB","site":"https://github.com/orbitdb/orbit-db","likes":200},{"project":"IPFS","site":"https://ipfs.io","likes":400}] |
| 281 | +``` |
| 282 | + |
| 283 | +To query a subset of data, a condition can be specified. For example, to |
| 284 | +retrieve only those entries which have a total number of likes above 300: |
| 285 | + |
| 286 | +```shell |
| 287 | +curl http://localhost:3000/db/docstore/query -X GET -H "Content-Type: application/json" --data '{"propname":"likes","comp":">","values":[300]}' |
| 288 | +``` |
| 289 | + |
| 290 | +```json |
| 291 | +[{"project":"IPFS","site":"https://ipfs.io","likes":400}] |
| 292 | +``` |
| 293 | + |
| 294 | +Available operator short-codes are: |
| 295 | + |
| 296 | +```eq``` propname equals value. Equivalent to "==" |
| 297 | + |
| 298 | +```ne``` propname is not equals to value. Equivalent to "!=" |
| 299 | + |
| 300 | +```gt``` propname is greater than value. Equivalent to ">" |
| 301 | + |
| 302 | +```lt``` propname is less than value. Equivalent to "<" |
| 303 | + |
| 304 | +```gte``` propname is greater than or equal to value. Equivalent to ">=" |
| 305 | + |
| 306 | +```lte``` propname is less than or equal to value. Equivalent to "<=" |
| 307 | + |
| 308 | +```mod``` Perform a modulus calculation on propname using value. Equivalent to "%" |
| 309 | + |
| 310 | +```range``` Perform a range query, comparing propname to min and max. |
| 311 | + |
| 312 | +```all``` Fetch all records for field propname. Equivalent to "*" |
| 313 | + |
| 314 | +#### Modulus Query |
| 315 | + |
| 316 | +When using a modulus query, you must supply the divisor and the remainder. For example, to obtain all likes which are multiples of 100, you would specify a divisor 100 and a remainder 0: |
| 317 | + |
| 318 | +```shell |
| 319 | +curl -X POST http://localhost:3000/db/docstore/query -H "Content-Type:application/json" --data '{"propname":"likes", "comp":"mod", "values":[100,0]}' |
| 320 | +``` |
| 321 | + |
| 322 | +```json |
| 323 | +[{"site":"https://ipfs.io","likes":400,"project":"IPFS"},{"site":"https://github.com/orbitdb/orbit-db","likes":200,"project":"OrbitDB"}] |
| 324 | +``` |
| 325 | + |
| 326 | +#### Range Query |
| 327 | + |
| 328 | +When specifying a range query, you must supply the min and max |
| 329 | +values. For example, to obtain all likes greater than 250 but less than 1000 the min and max must be supplied: |
| 330 | + |
| 331 | +```shell |
| 332 | +curl -X GET http://localhost:3000/db/docstore/query -H "Content-Type:application/json" --data '{"propname":"likes", "comp":"range", "values":[250,1000]}' |
| 333 | +``` |
| 334 | + |
| 335 | +```json |
| 336 | +[{"site":"https://ipfs.io","likes":400,"project":"IPFS"},{"site":"https://github.com/orbitdb/orbit-db","likes":200,"project":"OrbitDB"}] |
| 337 | +``` |
| 338 | + |
339 | 339 | ### POST|PUT /db/:dbname/add
|
340 | 340 |
|
341 | 341 | Adds a new entry to the eventlog or feed database :dbname.
|
|
0 commit comments