# Leaderboard

## AV. Leaderboard

#### new Leaderboard()

Source:
  - leaderboard.js, line 68

### Members

#### (nullable) createdAt :Date

Source:
  - leaderboard.js, line 96

##### Type:

- Date

#### (nullable) nextResetAt :Date

Source:
  - leaderboard.js, line 92

##### Type:

- Date

#### order :AV.LeaderboardOrder

Source:
  - leaderboard.js, line 76

##### Type:

- AV.LeaderboardOrder

#### statisticName :string

Source:
  - leaderboard.js, line 72

##### Type:

- string

#### updateStrategy :AV.LeaderboardUpdateStrategy

Source:
  - leaderboard.js, line 80

##### Type:

- AV.LeaderboardUpdateStrategy

#### version :number

Source:
  - leaderboard.js, line 88

##### Type:

- number

#### versionChangeInterval :AV.LeaderboardVersionChangeInterval

Source:
  - leaderboard.js, line 84

##### Type:

- AV.LeaderboardVersionChangeInterval

### Methods

#### (static) createLeaderboard(options, authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 117

(masterKey required) Create a new Leaderboard.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | Object |  | ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`statisticName` | string |  |
`order` | AV.LeaderboardOrder |  |
`versionChangeInterval` | AV.LeaderboardVersionChangeInterval | <optional> | default to WEEK
`updateStrategy` | AV.LeaderboardUpdateStrategy | <optional> | default to BETTER
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### (static) createWithoutData(statisticName) → {AV.Leaderboard}

Source:
  - leaderboard.js, line 105

Create an instance of Leaderboard for the give statistic name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`statisticName` | string |

##### Returns:

Type
  AV.Leaderboard

#### (static) getLeaderboard(statisticName, authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 141

Get the Leaderboard with the specified statistic name.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`statisticName` | string |  |
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### (static) getStatistics(user, optionsopt, authOptionsopt) → {Promise.<Array.<Statistic>>}

Source:
  - leaderboard.js, line 151

Get Statistics for the specified user.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`user` | AV.User |  | The specified AV.User pointer.
`options` | Object | <optional> | ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`statisticNames` | Array.<string> | <optional> | Specify the statisticNames. If not set, all statistics of the user will be fetched.
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Statistic>>

#### (static) updateStatistics(user, statistics, authOptionsopt) → {Promise.<Array.<Statistic>>}

Source:
  - leaderboard.js, line 181

Update Statistics for the specified user.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`user` | AV.User |  | The specified AV.User pointer.
`statistics` | Object |  | A name-value pair representing the statistics to update.
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Statistic>>

#### destroy(authOptionsopt) → {void}

Source:
  - leaderboard.js, line 332

(masterKey required) Delete the Leaderboard and its all archived versions.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  void

#### fetch(authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 229

Fetch data from the srever.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### getResults(optionsopt, authOptionsopt) → {Promise.<Array.<Ranking>>}

Source:
  - leaderboard.js, line 273

Retrieve a list of ranked users for this Leaderboard.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | Object | <optional> | ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`skip` | number | <optional> | The number of results to skip. This is useful for pagination.
`limit` | number | <optional> | The limit of the number of results.
`includeUserKeys` | Array.<string> | <optional> | Specify keys of the users to include
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Ranking>>

#### getResultsAroundUser(optionsopt, authOptionsopt) → {Promise.<Array.<Ranking>>}

Source:
  - leaderboard.js, line 284

Retrieve a list of ranked users for this Leaderboard, centered on the specified user.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | Object | <optional> | ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`limit` | number | <optional> | The limit of the number of results.
`includeUserKeys` | Array.<string> | <optional> | Specify keys of the users to include
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Ranking>>

#### reset(authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 318

(masterKey required) Reset the Leaderboard. The version of the Leaderboard will be incremented by 1.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### updateUpdateStrategy(updateStrategy, authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 310

(masterKey required) Update the version change interval of the Leaderboard.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`updateStrategy` | AV.LeaderboardUpdateStrategy |  |
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### updateVersionChangeInterval(versionChangeInterval, authOptionsopt) → {Promise.<AV.Leaderboard>}

Source:
  - leaderboard.js, line 301

(masterKey required) Update the version change interval of the Leaderboard.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`versionChangeInterval` | AV.LeaderboardVersionChangeInterval |  |
`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<AV.Leaderboard>