WIP feat: each track.url update matching providerTrack#45
Conversation
| return false | ||
| } | ||
|
|
||
| const ref = db.ref(`/providerTracks/${providerName}:${providerId}/tracks/${context.params.trackId}`); |
There was a problem hiding this comment.
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.
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.
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.
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.
does onWrite mean create+update? Does it also include delete?
There was a problem hiding this comment.
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:
trackmodel'surlis changed in the Radio4000 Firebase database, it will trigger a function that will create a matchingproviderTrackin the database, with forid:provider:providerId.trackis deleted, it's reference underproviderTracks/$providerTrackshould be deleted.