Namespace: CuriousObjects

curious.CuriousObjects

Utilities for dealing with curious objects
Source:

Classes

defaultType

Methods

(static) groupObjectsByID(arrayOfObjects) → {Array}

Take an array of objects that have 'id' fields, and group them into a single object using that field.
Parameters:
Name Type Description
arrayOfObjects Array.<Object> The array to turn into an object
Source:
Returns:
The values of the object, whatever it holds
Type
Array

(static) idList(objects) → {Array.<number>}

Take an array of objects that have id fields and pull those fields out into a list of only one ID each.

Preserves order.

Parameters:
Name Type Description
objects Array.<Object> An array of objects with the id property
Source:
Returns:
The set of IDs, with duplicates removed, in the same order as the input object list
Type
Array.<number>

(static) idString(arrayOfObjects) → {string}

Take an array of objects that have id fields and pull those fields out into a comma-separated string.

Preserves order.

Parameters:
Name Type Description
arrayOfObjects Array.<Object> The array to turn into an object
Source:
Returns:
A comma-separated string containing the objects' IDs, with duplicates removed, in the same order as the input object list
Type
string

(static) makeCamelCase(input) → {string}

Camel case a string with - or _ separators:
Parameters:
Name Type Description
input string The string to camel-case
Source:
Returns:
The input, camel-cased
Type
string
Example
CuriousObjects.makeCamelCase('this_is-someTHING') === 'thisIsSomething'
CuriousObjects.makeCamelCase('_alreadyDone') === '_alreadyDone'

(static) parse(relationships, customConstructors, queryJSONResponse, existingObjects, camelCaseopt) → {Object}

Get objects associated with each subquery. For each subquery, build a hash of ID to object. If existing objects are specified, will build relationships using the existing objects.
Parameters:
Name Type Attributes Description
relationships Array.<string> The names of the relationships objects will have to one another
customConstructors Array.<function(Object)> The custom constructors for curious object classes
queryJSONResponse Object An object of fields holding the query response, as returned and parsed directly from JSON without any post-processing
Properties
Name Type Description
computed_on string The query timestamp
last_model string The model name of the last set of objects returned
results Array.<Object> An array of objects containing Django object ids and other meta-information about the query; one element per model
Properties
Name Type Description
model string The model name for this part of the query
join_index number The index of the model this model joins to
objects Array.<Array> The IDs of the objects returned by the query
data Array.<Object> An array of objects containing the other fields of the Django objects, more than just the IDs--see module:curious.CuriousObjects~_parseObjects for a description of this data in the queryData parameter.
existingObjects Array.<Object.<number, Object>> The existing objects--each object in the array is a mapping of an id to its corresponding object.
camelCase boolean <optional>
If true, construct camel-cased versions of the JSON objects returned by the Curious server.
Source:
Returns:
The parsed objects--trees holds any hierarchical relationships, for recursive queries.
Type
Object

(static) values(obj) → {Array}

Utility for pulling out all the values contained in an object, in the same order as its keys would come out
Parameters:
Name Type Description
obj Object The object to look at
Source:
Returns:
The values of the object, whatever it holds
Type
Array