Page 1 of 1

How to use app.getObject

PostPosted: Mon Sep 04, 2017 4:03 am
by TIV73
Hi everybody,
I am having slight issues using app.getObject. It appears like the only working filter for album objects is id. To illustrate:

Code: Select all
app.getObject('album', {id:232})
.then(album => album.id)
.then(albumID => app.getObject('album', {id:albumID}))
.then(album => console.log(album))
// object is returned here


app.getObject('album', {id:232})
.then(album => album.title)
.then(albumTitle => app.getObject('album', {title:albumTitle}))
.then(album => console.log(album))
// nothing is returned


A screenshot to clarify:
Image

I realize that you wouldn't usually use the promise chain like that, I only wanted to illustrate that filtering by album title doesn't work, even if the filter values are provided by the object itself, therefore ruling out typos. I tried the same with name, albumArtist and _persistentID, with the same result. The filter only works when using id.

Is it supposed to work like this or am I using the function incorrectly? In other words - if I have the name of an album and I want to get the tracklist for that album, how would I do that? I could probably get the album ID from getQueryResultAsync and then use that for getObject, but that seems to be a somewhat roundabout way of doing something that's (supposedly) straighforward to do.

Re: How to use app.getObject

PostPosted: Mon Sep 04, 2017 4:31 am
by PetrCBR
You can locate album using app.getObject only by album ID, MusicBrainz Release GID (mbgid), MusicBrainz Release Group GID (mbrggid).
If you need to get album by it's name use app.db.getAlbumAsync instead (at least album and artist parameters are required).

Re: How to use app.getObject

PostPosted: Mon Sep 04, 2017 6:49 am
by TIV73
Perfect, that works for me. Thanks a lot for the help!