Query

General Structure

	[ // this is the outer array in case of an OR
		[ // this is an array that holds all of the individual filters
			{ // this is an object that holds all of the key/value pairs for a particular Operator
				"EQ": [
					{ // this is the operator
						"stringColumn": "stringValue" // the first value is the name of the column, the second is the value you wish to match
					}
				]
			},
			{
				"GT": [
					{ // this is another operator
						"intColumn": 4
					}
				]
			}
		] // if we had an or it would start after this line
	]

This structure would represent a query for all items whose stringColumn equal “stringValue” and whose intColumn is greater than 4

This structure can be used to match when doing a GET, PUT, or DELETE, but each have this structure wrapped in an object specific to that method.

Method Specific Structure

GET

A request that uses the GET method should have the following in a querystring with ‘query’ as the key:

	{
		"SORT": [ // the sort key dictates what order the data is returned in
			{
				"ASC":"columnName" // the key for each entry in sort is either "ASC" or "DESC"
			} // if sorting by more than one column the next entry would get its own object following this line
		],
		"PAGESIZE": 100, // this is the amount of items that will be returned from a request. (default: 100)
		"PAGENUM": 1, // this is the page number based on the above pagesize given (default: 1)
		"FILTERS": [[{"EQ": [{"stringColumn": "stringValue"}]},{"GT": [{"intColumn": 4}]}]] // this is the same stucture as defined in "General Structure" above. 
	}

This is then URL encoded and transmitted like:

platformIP/api/v/1/data/<collectionID>?query=%7B%22SORT%22%3A%5B%7B%22ASC%22%3A%22columnName%22%7D%5D%2C%22PAGESIZE%22%3A%20100%2C%22PAGENUM%22%3A%201%2C%20%22FILTERS%22%3A%20%5B%5B%7B%22EQ%22%3A%20%7B%22stringColumn%22%3A%20%22stringValue%22%7D%7D%2C%7B%22GT%22%3A%20%7B%22intColumn%22%3A%204%7D%7D%5D%5D%7D%0A

PUT

A request that uses the PUT method should have the following in the body of the request:

	{
		"query":[[{"EQ": [{"stringColumn": "stringValue"}]},{"GT": [{"intColumn": 4}]}]], // this is the same structure as defined in "General Structure" above.
		"$set": {"column": "newValue"}
	}

DELETE

A request that uses the DELETE method should have the following in a querystring with ‘query’ as the key:

	[[{"EQ": [{"stringColumn": "stringValue"}]},{"GT": [{"intColumn": 4}]}]] // this is the same structure as defined in "General Structure" above.

This is then URL encoded and transmitted like:

platformIP/api/v/1/data/<collectionID>?query=%5B%5B%7B%22EQ%22%3A%20%7B%22stringColumn%22%3A%20%22stringValue%22%7D%7D%2C%7B%22GT%22%3A%20%7B%22intColumn%22%3A%204%7D%7D%5D%5D

Filtering

Filtering is an aspect of querying. Essentially it is the part of the query analogous to the “where” clause in a regular SQL query.

Let’s refresh ourselves with the filtering structure:

	[ // this is the outer array in case of an OR
		[ // this is an array that holds all of the individual filters
			{ // this is an object that holds all of the key/value pairs for a particular Operator
				"EQ": [
					{ // this is the operator
						"stringColumn": "stringValue" // the first value is the name of the column, the second is the value you wish to match
					}
				]
			},
			{
				"GT": [
					{ // this is another operator
						"intColumn": 4
					}
				]
			}
		] // if we had an or it would start after this line
	]

On the outermost level, we have the OR queries. Or queries hold multiple AND queries inside of them. Like so:

	[
		[{Foo is Equal To "Quux"}],    //one Or Branch
		[{Bar is Not Equal To "Spam"}] //another Or Branch
	]

What this translates to is “WHERE Foo = ‘Quux’ OR Bar = ‘Spam’”.

Now let’s cover AND statements.

	[
		[{Foo is Equal To "Quux"}, {Bar is Equal To "Spam"}]
	]

This translates to “WHERE Foo = ‘Quux’ AND Bar = ‘Spam’”.

It’s important to note here that we still have the OR wrapper around the query, but it only has one branch.

We can add arbitrarily many conditions like this together, and we’ll still be presenting the platform a valid filter. As long as the filter matches an entry in your collection, it will return something.

At present JOINs across collections is not allowed, but may be added in the future.