ModPresets
db.modpresets.get returns read-only snapshots for mod presets. 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 mod presets in a regular array.
return db.modpresets.get
.all()
.map(item => ({
name: item.Name,
mods: item.Mods,
}))toArray
Returns all matching mod presets in a regular array.
return db.modpresets.get
.toArray()
.map(item => ({
name: item.Name,
mods: item.Mods,
}))first
Returns the first matching mod preset, or undefined.
return db.modpresets.get
.first()?.Namecount
Counts all matching mod presets, even when a limit is set.
return db.modpresets.get
.count()limit
Limits how many mod presets elements are accessed.
return db.modpresets.get
.limit(1)
.map(item => ({
name: item.Name,
mods: item.Mods,
}))sortedBy
Sorts mod presets by a database field.
return db.modpresets.get
.sortedBy('Name')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))autoEdit
Starts an edit session that buffers changes to matching mod presets. Commit or roll them back when you are done.
const session = db.modpresets.get
.limit(1)
.autoEdit()
const length = session.length
session.rollback()
return lengthcommit
Saves the pending changes.
const session = db.modpresets.get
.limit(1)
.autoEdit()
const length = session.length
session.commit()
return lengthrollback
Discards the pending changes.
const session = db.modpresets.get
.limit(1)
.autoEdit()
const length = session.length
session.rollback()
return lengthwrite.delete
Deletes every matching mod preset in one transaction.
return db.modpresets.get
.limit(1)
.write.delete()write.update
Applies a typed patch to every matching mod preset.
return db.modpresets.get
.limit(1)
.write.update({ Name: 'Example' })byDeletePending
Finds mod presets where delete pending matches the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byDeletePending(true)
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byDescriptionContains
Finds mod presets where description contains the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byDescriptionContains('hidden')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byId
Finds mod presets where ID matches the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byId('cccccccc-cccc-4ccc-8ccc-cccccccccccc')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byModsContains
Finds mod presets where mods contains the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byModsContains('HD')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byName
Finds mod presets where name matches the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byName('HD')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byNameContains
Finds mod presets where name contains the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byNameContains('DT')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))byRuleset
Finds mod presets where ruleset matches the supplied value. You can chain more filters on the result.
return db.modpresets.get
.byRuleset('osu')
.map(item => ({
name: item.Name,
mods: item.Mods,
}))