dbgcensus
A simple way to use the Daybreak Games Census API service
Table of Contents
- Installing
- Creating a new query
- Returning data from the query
- Setting global parameters
- Defining a condition
- Setting a language
- Show certain fields
- Hide certain fields
- Set a limit for number of rows to return
- Set the starting row
- Add a resolve
- Join to another service
- Tree results on a field
- Getting the url of the query
Installing
npm install dbgcensus --save
Creating a new query
var CensusQuery = Query;var query = 'character' 'ps2' 'example'
The dbgcensus.Query constructor accepts a service, optional serviceType, and optional serviceId. If a globalNamespace
is not set than that argument becomes required. The acceptable namespaces can be found on the census.daybreakgames.com website. If a serviceId is not provided it defaults to the globalKey
if one is set or 'example'.
Returning data from the query
query;
The data
variable represents the data of the collection list. Normally when a query is made with the census API it is returned like:
character_list: 'character_id': 1234 //etc
However dbgcensus returns just the data so the above becomes:
'character_id': 1234 //etc
Setting global parameters
var dbgcensus = ;dbgcensus;dbgcensus;
Defining a condition
query;
The following operations and their equivalent syntax is below:
equals
: =notEquals
: =!isLessThan
: =<isLessThanOrEquals
: =[isGreaterThan
: =>isGreaterThanOrEquals
: =]startsWith
: =^contains
: =*
Setting a language
query;
No language is set by default so you will receive all localized strings if available.
Show certain fields
query;
Hide certain fields
query;
Set a limit for number of rows to return
query;
Set the starting row
query;
Add a resolve
query;
or for multiple resolves
query;
Join to another service
var worldJoin = query;
Join objects have the following methods:
isList(bool)
isOuterJoin(bool)
showFields(array)
: See the 'Show certain fields' section abovehideFields(array)
: See the 'Hide certain fields' section aboveonField(string)
toField(string)
injectAt(string)
where(string)
: See the 'Defining a condition' section abovejoinService(string)
: Returns another join object for sub joining
Tree results on a field
var query = 'vehicle' 'ps2';var vehicleTree = query;
Tree objects have the following methods:
isList(bool)
groupPrefix(string)
startField(string)
treeField(string)
: Returns another tree object for sub grouping
Getting the url of the query
var url = query;