Query
The class that represents a StubHub Query.
Extends
new Query()
Members
Methods
eventQuery
(static) eventQuery(queryParams) → {Query}
Create an event query with a predefined QueryParams Objects enum value.
Parameters
Name | Type | Description |
---|---|---|
queryParams | A predefined QueryParam enum value.
|
Returns
Example
var Query = StubHubJS.Query, QueryParam = StubHubJS.QueryParam; // Using a single query parameter var query = Query.eventQuery(QueryParam.SPORTS); // Using mulitple query parameters var query = Query.eventQuery(QueryParam.NBA, QueryParam.EXCLUDE_PARKING);var Que
contains
contains(key, substring) → {Query}
Searches for string values that contain the provided string.
NOTE: If you are performing this query on a large dataset, the search may take more processing time to return the results.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key that the string to match is stored in.
|
substring | String | Array.
| The substring that the value must contain, or a list of substrings that at least one of the substrings contains the provided string.
|
Inherited From
Returns
date
date(d) → {Query}
Parameters
Name | Type | Description |
---|---|---|
d | String | Date
| A date string in the format yyyy-MM-dd or a JavaScript Date object.
|
Inherited From
Returns
equalTo
equalTo(key, value) → {Query}
Restricts the query to return only the value of a key that is equal to the provided value.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key to search for.
|
value | String | Array.<String>
| The value of the key to match, or a list of comma-separated values to find at least one match.
|
Inherited From
Returns
find
find(callback)
Executes the Query to get results.
Parameters
Name | Type | Description |
---|---|---|
callback | function | The method that is called for executing the query. Returns the search results or errors.
|
Example
var query = new Query('Event'); query.select('*'); query.offset(10); query.limit(10); query.equalTo('performerName', 602); query.find(function(err, results){ if(!err && results){ var numFound = results.numFound; //paginate the results var events = results.events; //... some codes } //... other codes });
hasTicket
hasTicket(b) → {Query}
Parameters
Name | Type | Description |
---|---|---|
b | Boolean | True means search for an event that has tickets on sale. False means ignore the event that has tickets on sale.
|
Inherited From
Returns
limit
limit(n) → {Query}
Sets the limit on number of results to return.
Parameters
Name | Type | Description |
---|---|---|
n | Number | The maximum number of results to return.
|
Inherited From
Returns
localDate
localDate(d) → {Query}
Parameters
Name | Type | Description |
---|---|---|
d | String | Date
| A date string in the format yyyy-MM-dd(THH:mm) or a JavaScript Date object.
|
Inherited From
Returns
localDateRange
localDateRange(start, end) → {Query}
Parameters
Name | Type | Description |
---|---|---|
start | String | Date
| The beginning of the date range. Specify this as a string in the format yyyy-MM-dd or as a JavaScript Date object.
|
end | String | Date
| The end of the date range. Specify this as a string in the format yyyy-MM-dd or as a JavaScript Date object.
|
Inherited From
Returns
locateAt
locateAt(location) → {Query}
Specify a property of the location object to search for.
NOTE: This method only applies to a Query object whose type is Event or Venue.
Parameters
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
location | Object | Represents the location object, which has the properties as described in the table below. Properties
|
Inherited From
Returns
notContains
notContains(key, substring) → {Query}
Searches for string values that do not contain a provided string.
NOTE: If you are performing this query on a large dataset, the search may take more processing time to return the results.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key that the string to match is stored in.
|
substring | String | The substring that the value must not contain.
|
Inherited From
Returns
notEqualTo
notEqualTo(key, value) → {Query}
Adds a constraint for finding string values that do not match a provided string.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key that the non-matching string is stored in.
|
value | String | The value to eliminate from the query results.
|
Inherited From
Returns
offset
offset(n) → {Query}
Sets the number of results to skip before returning any results.
Parameters
Name | Type | Description |
---|---|---|
n | String | The number of results to skip.
|
Inherited From
Returns
select
select(f) → {Query}
Restricts the fields that the object(s) returns.
Parameters
Name | Type | Description |
---|---|---|
f | String | The names of the fields in comma-separated-value (CSV) format (such as select ('city', 'state', 'country').
|
Inherited From
Returns
sort
sort() → {Query}
Sort the query results.
NOTE: Each type of Query has a different set of available sort fields. See the examples below.
Parameters
Inherited From
Returns
Example
// For an event query, the available sort fields are 'popularity', 'name','eventDateLocal', or 'distance'. new Query('Event').sort('eventDateLocal'); // For a venue query, the available sort fields are 'name', or 'distance'. new Query('Venue').sort('distance'); // For a performer query, the available sort field is 'name'. new Query('Performer').sort('name');
withInMiles
withInMiles(point, Maximum) → {Query}
Specifies the maxmium distance (or radius) from a given GeoPoint that a query searches for events.
NOTE: This method only applies to a Query object that has a type of Event or Venue.
Parameters
Name | Type | Description |
---|---|---|
point | Refers to the specified GeoPoint.
| |
Maximum | Number | The distance (in miles) of results to return.
|
Inherited From
Returns
dateRange
dateRange(start, end) → {Query}
Parameters
Name | Type | Description |
---|---|---|
start | String | Date
| The beginning of the date range. This is specified as a string in the format yyyy-MM-dd or as a JavaScript Date object.
|
end | String | Date
| The end of the date range. This is specified as a string in the format yyyy-MM-dd or as a JavaScript Date object.
|