Metadata
db.metadata.get returns read-only snapshots for metadata records. 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 metadata records in a regular array.
return db.metadata.get
.all()
.map(item => ({
title: item.Title,
artist: item.Artist,
}))toArray
Returns all matching metadata records in a regular array.
return db.metadata.get
.toArray()
.map(item => ({
title: item.Title,
artist: item.Artist,
}))first
Returns the first matching metadata record, or undefined.
return db.metadata.get
.first()?.Titlecount
Counts all matching metadata records, even when a limit is set.
return db.metadata.get
.count()limit
Limits how many metadata records elements are accessed.
return db.metadata.get
.limit(1)
.map(item => ({
title: item.Title,
artist: item.Artist,
}))sortedBy
Sorts metadata records by a database field.
return db.metadata.get
.sortedBy('Title')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byArtist
Finds metadata records where artist matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byArtist('Icon For Hire')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byArtistContains
Finds metadata records where artist contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byArtistContains('Hire')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byArtistUnicode
Finds metadata records where artist unicode matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byArtistUnicode('アイコン・フォー・ハイヤー')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byArtistUnicodeContains
Finds metadata records where artist unicode contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byArtistUnicodeContains('アイコン')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byAudioFile
Finds metadata records where audio file matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byAudioFile('audio.mp3')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byAuthorOnlineId
Finds metadata records where author online ID matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byAuthorOnlineId(124493)
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byAuthorUsernameContains
Finds metadata records where author username contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byAuthorUsernameContains('wajinshu')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byBackgroundFile
Finds metadata records where background file matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byBackgroundFile('background.jpg')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byPreviewTimeAbove
Finds metadata records where preview time is above the supplied value. You can chain more filters on the result.
return db.metadata.get
.byPreviewTimeAbove(30000)
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byPreviewTimeBelow
Finds metadata records where preview time is below the supplied value. You can chain more filters on the result.
return db.metadata.get
.byPreviewTimeBelow(60000)
.map(item => ({
title: item.Title,
artist: item.Artist,
}))bySource
Finds metadata records where source matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.bySource('osu!')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))bySourceContains
Finds metadata records where source contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.bySourceContains('osu')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byTagsContains
Finds metadata records where tags contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byTagsContains('rock')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byTitle
Finds metadata records where title matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byTitle('Make A Move')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byTitleContains
Finds metadata records where title contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byTitleContains('Move')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byTitleUnicode
Finds metadata records where title unicode matches the supplied value. You can chain more filters on the result.
return db.metadata.get
.byTitleUnicode('メイク・ア・ムーブ')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))byTitleUnicodeContains
Finds metadata records where title unicode contains the supplied value. You can chain more filters on the result.
return db.metadata.get
.byTitleUnicodeContains('メイク')
.map(item => ({
title: item.Title,
artist: item.Artist,
}))