Class Index | File Index

Classes


Namespace db

Functions that directly access an IndexedDB database.
Defined in: <js/db.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
db
Method Summary
Method Attributes Method Name and Description
<static>  
db.getObjectStore(ot, transactionObjectStores, objectStore, readwrite)
Get an object store or transaction based on input which may be the desired object store, a transaction to be used, or null.
<static>  
db.getPayroll(ot, tid, cb)
Get the total payroll for a team.
<static>  
db.getPlayer(pa, season, tid, attributes, stats, ratings, options)
Get a filtered player object.
<static>  
db.getPlayers(playersAll, season, tid, attributes, stats, ratings, options)
Get an array of filtered player objects.
<static>  
db.getTeam(ta, season, attributes, stats, seasonAttributes, options)
Get a filtered team object.
<static>  
db.getTeams(ot, season, attributes, stats, seasonAttributes, options, sortBy, cb)
Get an array of filtered team objects.
<static>  
db.putPlayer(ot, p, cb)
Add a new player to the database or update an existing player.
<static>  
db.rosterAutoSort(ot, tid, cb)
Sort a team's roster based on player ratings.
Namespace Detail
db
Method Detail
<static> {(IDBObjectStore|IDBTransaction)} db.getObjectStore(ot, transactionObjectStores, objectStore, readwrite)
Get an object store or transaction based on input which may be the desired object store, a transaction to be used, or null. This allows for the convenient use of transactions or object stores that have already been defined, which is often necessary.
Parameters:
{(IDBObjectStore|IDBTransaction|null)} ot
An IndexedDB object store or transaction to be used; if null is passed, then a new transaction will be used.
{(string|Array.)} transactionObjectStores
The object stores to open a transaction with, if necessary.
{?string} objectStore
The object store to return. If null, return a transaction.
{boolean=} readwrite
Should the transaction be readwrite or not? This only applies when a new transaction is created here (i.e. no transaction or objectStore is passed). Default false.
Returns:
{(IDBObjectStore|IDBTransaction)} The requested object store or transaction.

<static> db.getPayroll(ot, tid, cb)
Get the total payroll for a team. This includes players who have been released but are still owed money from their old contracts.
Parameters:
{IDBTransaction|null} ot
An IndexedDB transaction on players and releasedPlayers; if null is passed, then a new transaction will be used.
{number} tid
Team ID.
{function(Array)} cb
Callback whose first argument is the payroll in thousands of dollars.

<static> {Object} db.getPlayer(pa, season, tid, attributes, stats, ratings, options)
Get a filtered player object. For a player object (pa), create an object suitible for output based on the appropriate season and tid. attributes, stats, and ratings are lists of keys. In the output, the attributes keys will be in the root of the object. There will also be stats and ratings properties containing the filtered stats and ratings objects, if appropriate. If season is null, then the stats and ratings objects will contain lists of objects for each season and tid is ignored. Then, there will also be a careerStats property in the output object containing an object with career averages. This function is overcomplicated and convoluted.
Parameters:
{Object} pa
Player object.
{?number} season
Season to retrieve stats/ratings for. If null, return stats/ratings for all seasons in a list as well as career totals in player.careerStats.
{?number} tid
Team ID to retrieve stats for. This is useful in the case where a player played for multiple teams in a season. Eventually, there should be some way to specify whether the stats for multiple teams in a single season should be merged together or not. For now, passing null just picks the first entry, which is clearly wrong.
{Array.} attributes
List of player attributes to include in output.
{Array.} stats
List of player stats to include in output.
{Array.} ratings
List of player ratings to include in output.
{Object} options
Object containing various options. Possible keys include... "totals": Boolean representing whether to return total stats (true) or per-game averages (false); default is false. Other keys should eventually be documented.
Returns:
{Object} Filtered object containing the requested information for the player.

<static> db.getPlayers(playersAll, season, tid, attributes, stats, ratings, options)
Get an array of filtered player objects. After the first argument, all subsequent arguments are passed on to db.getPlayer, where further documentation can also be found.
Parameters:
{Array} playersAll
Array of player objects.
season
tid
attributes
stats
ratings
options

<static> db.getTeam(ta, season, attributes, stats, seasonAttributes, options)
Get a filtered team object. See db.getTeams for documentation.
Parameters:
ta
season
attributes
stats
seasonAttributes
options

<static> db.getTeams(ot, season, attributes, stats, seasonAttributes, options, sortBy, cb)
Get an array of filtered team objects.
Parameters:
{(IDBTransaction|null)} ot
An IndexedDB transaction on players, releasedPlayers, and teams; if null is passed, then a new transaction will be used.
{number} season
Season to retrieve data for.
{Array.} attributes
List of non-seasonal attributes (such as team name) to include in output.
{Array.} stats
List of team stats to include in output.
{Array.} seasonAttributes
List of seasonal attributes (such as won or lost) to include in output.
{Object} options
Object containing various options. Possible keys include... "sortBy": String represeting the sorting method; "winp" sorts by descending winning percentage, "winpAsc" does the opposite, default is sort by team ID. "totals": Boolean representing whether to return total stats (true) or per-game averages (false); default is false.
{string|null} sortBy
String represeting the sorting method. "winp" sorts by descending winning percentage, "winpAsc" does the opposite.
{function(Array)} cb
Callback whose first argument is an array of all the team objects.

<static> db.putPlayer(ot, p, cb)
Add a new player to the database or update an existing player.
Parameters:
{IDBObjectStore|IDBTransaction|null} ot
An IndexedDB object store or transaction on players, readwrite; if null is passed, then a new transaction will be used.
{Object} p
Player object.
{function()=} cb
Optional callback.

<static> db.rosterAutoSort(ot, tid, cb)
Sort a team's roster based on player ratings.
Parameters:
{(IDBObjectStore|IDBTransaction|null)} ot
An IndexedDB object store or transaction on players readwrite; if null is passed, then a new transaction will be used.
{number} tid
Team ID.
{function()=} cb
Optional callback.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 01 2013 11:45:19 GMT-0500 (EST)