Keybindings
db.keybindings.get returns read-only snapshots for keybindings. 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 keybindings in a regular array.
return db.keybindings.get
.all()
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))toArray
Returns all matching keybindings in a regular array.
return db.keybindings.get
.toArray()
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))first
Returns the first matching keybinding, or undefined.
return db.keybindings.get
.first()?.KeyCombinationcount
Counts all matching keybindings, even when a limit is set.
return db.keybindings.get
.count()limit
Limits how many keybindings elements are accessed.
return db.keybindings.get
.limit(1)
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))sortedBy
Sorts keybindings by a database field.
return db.keybindings.get
.sortedBy('Action')
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))autoEdit
Starts an edit session that buffers changes to matching keybindings. Commit or roll them back when you are done.
const session = db.keybindings.get
.limit(1)
.autoEdit()
const length = session.length
session.rollback()
return lengthcommit
Saves the pending changes.
const session = db.keybindings.get
.limit(1)
.autoEdit()
const length = session.length
session.commit()
return lengthrollback
Discards the pending changes.
const session = db.keybindings.get
.limit(1)
.autoEdit()
const length = session.length
session.rollback()
return lengthwrite.delete
Deletes every matching keybinding in one transaction.
return db.keybindings.get
.limit(1)
.write.delete()write.update
Applies a typed patch to every matching keybinding.
return db.keybindings.get
.limit(1)
.write.update({ KeyCombination: 'Z' })byAction
Finds keybindings where action matches the supplied value. You can chain more filters on the result.
return db.keybindings.get
.byAction(1)
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))byId
Finds keybindings where ID matches the supplied value. You can chain more filters on the result.
return db.keybindings.get
.byId('bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb')
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))byRulesetName
Finds keybindings where ruleset name matches the supplied value. You can chain more filters on the result.
return db.keybindings.get
.byRulesetName('osu')
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))byVariant
Finds keybindings where variant matches the supplied value. You can chain more filters on the result.
return db.keybindings.get
.byVariant(0)
.map(item => ({
ruleset: item.RulesetName,
action: item.Action,
key: item.KeyCombination,
}))