Based on Express and Mongoose
This software is currently in it's beta stage. The newest versions might (and most likely will) break the backwards compatibility.
const app = require('rdata-query-server');
app.run();
The Query Server is a REST Api server that allows users to pull the data back from the database.
The events and contexts logged by rdata-server are returned in a form of REST resources.
Before you make a query, you must provide a valid access token in the Authorization
HTTP header, or URL/body parameter accessToken
.
The HTTP header must look like this:
Key | Value |
---|---|
Authorization | Bearer: TOKEN123456... |
Please, refer to the rdata-auth-server for more information regarding access and refresh tokens.
This server provides 2 REST Api endpoints, /contexts
and /events
.
The same querying rules are applied to both of them.
You can provide the following query paremeters to query the data:
Source | Key | Description | Default value | Example value |
---|---|---|---|---|
GET params or body | query |
Query for filtering the data. See MongoDB documentation for the detailed documentation | {} | { "name": "MyGameEvent" } |
GET params | skip |
Skips the provided number of documents | 0 | 5 |
GET params | limit |
Limits the number of document by the provided amount | 0 | 15 |
GET params | sort |
Sorts the result by the provided rule. See MongoDB documentation for the detailed documentation | {} | { "time": "asc" } |
You can provide a MongoDB-style query for filtering the documents.
Here are some useful examples:
{ "name": "MyAwesomeContext" }
- returns only "MyAwesomeContext" contexts
{ "name": {"$in": ["MyAwesomeContext", "MySuperContext"]} }
- returns only "MyAwesomeContext" and "MySuperContext" contexts
{ "data.isCorrect": true }
- returns contexts with data.isCorrect being true
{ "timeStarted": {"$gte": 1493742320562 } }
- returns contexts that started after 1493742320562. Please note that all dates are logged in the UNIX timestamp format, which is a number of milliseconds passed since Jan 1, 1970 00:00:00 UTC. You can use this converter to convert between unix timestamp and date/time. Please be aware that unix timestamp is UTC and not your local time.
{ "timeEnded": {"$lte": 1493742320562 } }
- returns contexts that ended before 1493742320562
Skips first number of elements
Limits the output by the provided number of elements
Sorts the output by the provided rule. The rule should be compatible with Mongodb sort() function. Examples:
{ "time": "asc" }
- sorts by the event time in the ascending order
{ "name": 1 }
- sorts by the name in the ascending order
{ "timeStarted": "desc" }
- sorts by the time started in the descending order
{ "timeEnded": -1 }
- sorts by the time ended in the descending order