Skip to content

Scores ​

db.scores.get returns read-only snapshots for scores. You can keep chaining filters or use normal array methods.

These examples use a small fixture that resets for every run. Your application still uses its own Realm database.

all ​

Returns all matching scores in a regular array.

ts
return db.scores.get
  .all()
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

toArray ​

Returns all matching scores in a regular array.

ts
return db.scores.get
  .toArray()
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

first ​

Returns the first matching score, or undefined.

ts
return db.scores.get
  .first()?.PP

count ​

Counts all matching scores, even when a limit is set.

ts
return db.scores.get
  .count()

limit ​

Limits how many scores elements are accessed.

ts
return db.scores.get
  .limit(1)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

sortedBy ​

Sorts scores by a database field.

ts
return db.scores.get
  .sortedBy('Date')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

autoEdit ​

Starts an edit session that buffers changes to matching scores. Commit or roll them back when you are done.

ts
const session = db.scores.get
  .limit(1)
  .autoEdit()
const length = session.length
session.rollback()
return length

commit ​

Saves the pending changes.

ts
const session = db.scores.get
  .limit(1)
  .autoEdit()
const length = session.length
session.commit()
return length

rollback ​

Discards the pending changes.

ts
const session = db.scores.get
  .limit(1)
  .autoEdit()
const length = session.length
session.rollback()
return length

write.delete ​

Deletes every matching score in one transaction.

ts
return db.scores.get
  .limit(1)
  .write.delete()

write.update ​

Applies a typed patch to every matching score.

ts
return db.scores.get
  .limit(1)
  .write.update({ PP: 0 })

byAccuracyAbove ​

Finds scores where accuracy is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byAccuracyAbove(0.95)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byAccuracyBelow ​

Finds scores where accuracy is below the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byAccuracyBelow(0.5)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byBackgroundReprocessingFailed ​

Finds scores where background reprocessing failed matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byBackgroundReprocessingFailed(true)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byBeatmapId ​

Finds scores where beatmap ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byBeatmapId('11111111-1111-4111-8111-111111111111')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byBeatmapMd5 ​

Finds scores where beatmap MD5 matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byBeatmapMd5('b'.repeat(32))
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byBeatmapOnlineId ​

Finds scores where beatmap online ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byBeatmapOnlineId(506483)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byBeatmapSetOnlineId ​

Finds scores where beatmap set online ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byBeatmapSetOnlineId(506483)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byClientVersion ​

Finds scores where client version matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byClientVersion('20131110')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byComboAbove ​

Finds scores where combo is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byComboAbove(300)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byComboBelow ​

Finds scores where combo is below the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byComboBelow(100)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byDateAfter ​

Finds scores where date is after the supplied date. You can chain more filters on the result.

ts
return db.scores.get
  .byDateAfter(new Date('2024-01-01'))
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byDateBefore ​

Finds scores where date is before the supplied date. You can chain more filters on the result.

ts
return db.scores.get
  .byDateBefore(new Date('2024-01-01'))
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byDeletePending ​

Finds scores where delete pending matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byDeletePending(true)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byId ​

Finds scores where ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byId('44444444-4444-4444-8444-444444444444')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byIsLegacyScore ​

Finds scores where is legacy score matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byIsLegacyScore(true)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byLegacyOnlineId ​

Finds scores where legacy online ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byLegacyOnlineId(1518856368)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byMaxComboAbove ​

Finds scores where max combo is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byMaxComboAbove(500)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byMaxComboBelow ​

Finds scores where max combo is below the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byMaxComboBelow(1000)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byModsContains ​

Finds scores where mods contains the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byModsContains('HD')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byOnlineId ​

Finds scores where online ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byOnlineId(1518856368)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byPpAbove ​

Finds scores where PP is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byPpAbove(300)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byRank ​

Finds scores where rank matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byRank(5)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byRankAbove ​

Finds scores where rank is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byRankAbove(4)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byRuleset ​

Finds scores where ruleset matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byRuleset('osu')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byTotalScoreAbove ​

Finds scores where total score is above the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byTotalScoreAbove(1000000)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byTotalScoreBelow ​

Finds scores where total score is below the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byTotalScoreBelow(500000)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byUserCountryCode ​

Finds scores where user country code matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byUserCountryCode('KR')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byUserId ​

Finds scores where user ID matches the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byUserId(124493)
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

byUsernameContains ​

Finds scores where username contains the supplied value. You can chain more filters on the result.

ts
return db.scores.get
  .byUsernameContains('Cookiezi')
  .map(item => ({
    pp: item.PP,
    accuracy: item.Accuracy,
    username: item.User?.Username,
  }))

Released under the MIT License.