# Leaderboard

## AV. Leaderboard

#### new Leaderboard()

Source:
  - leaderboard.js, line 86

### Members

#### (nullable) createdAt :Date

Source:
  - leaderboard.js, line 114

##### Type:

- Date

#### (nullable) nextResetAt :Date

Source:
  - leaderboard.js, line 110

##### Type:

- Date

#### order :AV.LeaderboardOrder

Source:
  - leaderboard.js, line 94

##### Type:

- AV.LeaderboardOrder

#### statisticName :string

Source:
  - leaderboard.js, line 90

##### Type:

- string

#### updateStrategy :AV.LeaderboardUpdateStrategy

Source:
  - leaderboard.js, line 98

##### Type:

- AV.LeaderboardUpdateStrategy

#### version :number

Source:
  - leaderboard.js, line 106

##### Type:

- number

#### versionChangeInterval :AV.LeaderboardVersionChangeInterval

Source:
  - leaderboard.js, line 102

##### Type:

- AV.LeaderboardVersionChangeInterval

### Methods

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

Source:
  - leaderboard.js, line 135

(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 123

Create an instance of Leaderboard for the give statistic name.

##### Parameters:

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

##### Returns:

Type
  AV.Leaderboard

#### (static) deleteStatistics(user, statistics, optionsopt) → {Promise.<void>}

Source:
  - leaderboard.js, line 218

Delete 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 delete.
`options` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<void>

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

Source:
  - leaderboard.js, line 159

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 169

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, optionsopt) → {Promise.<Array.<Statistic>>}

Source:
  - leaderboard.js, line 192

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.

`options`

AuthOptions

<optional>

AuthOptions plus:

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`overwrite` | boolean | <optional> | Wethere to overwrite these statistics disregarding the updateStrategy of there leaderboards

##### Returns:

Type
  Promise.<Array.<Statistic>>

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

Source:
  - leaderboard.js, line 389

(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 255

Fetch data from the srever.

##### Parameters:

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

##### Returns:

Type
  Promise.<AV.Leaderboard>

#### getArchives(optionsopt, authOptionsopt) → {Promise.<Array.<LeaderboardArchive>>}

Source:
  - leaderboard.js, line 404

(masterKey required) Get archived versions.

##### 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.

`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<LeaderboardArchive>>

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

Source:
  - leaderboard.js, line 312

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.
`selectUserKeys` | Array.<string> | <optional> | Specify keys of the users to include
`includeStatistics` | Array.<string> | <optional> | Specify other statistics to include in the Rankings
`version` | number | <optional> | Specify the version of the leaderboard

`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Ranking>>

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

Source:
  - leaderboard.js, line 332

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

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`user` | AV.User |  | The specified AV.User pointer.

`options`

Object

<optional>

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`limit` | number | <optional> | The limit of the number of results.
`selectUserKeys` | Array.<string> | <optional> | Specify keys of the users to include
`includeStatistics` | Array.<string> | <optional> | Specify other statistics to include in the Rankings
`version` | number | <optional> | Specify the version of the leaderboard

`authOptions` | AuthOptions | <optional> |

##### Returns:

Type
  Promise.<Array.<Ranking>>

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

Source:
  - leaderboard.js, line 375

(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 367

(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 358

(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>