-
Notifications
You must be signed in to change notification settings - Fork 3
WIP feat: each track.url update matching providerTrack #45
base: master
Are you sure you want to change the base?
Conversation
return false | ||
} | ||
|
||
const ref = db.ref(`/providerTracks/${providerName}:${providerId}/tracks/${context.params.trackId}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about splitting providerName
and providerId
with a slash as well? Instead of the :
. So you don't have to parse the string to figure out which provider it is. Easier to query with firebase I assume.
ala
https://media.now.sh/youtube/YyI52_FEYgY
https://media.now.sh/vimeo/121814744
https://media.now.sh/discogs/1728315
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the DB looks like this
- providerTracks
- - youtube:OkR7UNnQU6c
So if you want to query it with ember your just do store.find('providerTrack', 'youtube:OkR7UNnQU6c')
.
If you separate the provider with a slash how would you query the providerTrack
that has the youtube id OkR7UNnQU6c
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Not sure how to query that either. Maybe different models. Each extend providerTrack
so the adapter can specify the endpoints: this.store.find('youtube-track', id)
? Ala what we do on the Explorer for Discogs.
If we have discogs:123
and youtube:456
. How do you query all Discogs tracks?
Another idea is to move the provider to to a property? {id: '123', provider: 'youtube'}
. Then it's easy to filter and query. Trying to think of the pros and cons..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that there is a misunderstanding on the point of this new model.
I will try to make a summary to explain the idea better.
// Listen to every track change | ||
exports.onTrackUrlChange = | ||
functions.database.ref('/tracks/{trackId}/url') | ||
.onWrite(onTrackUrlChange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does onWrite
mean create+update? Does it also include delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onWrite(), which triggers when data is created, updated, or deleted in the Realtime Database.
Source: https://firebase.google.com/docs/functions/database-events
This PR has for objective:
track
model'surl
is changed in the Radio4000 Firebase database, it will trigger a function that will create a matchingproviderTrack
in the database, with forid
:provider:providerId
.track
is deleted, it's reference underproviderTracks/$providerTrack
should be deleted.