Is there any way to include a user's authentication uid in a model adapter's path? For example, suppose you have a chat application, and a conversation
model to represent a private message session between two users, where the data is stored something like this:
{
"conversations": {
"<userAuthUID>": {
"convo1": {...},
"convo2": {...},
...
},
"<anotherUserAuthUID>": {
...
}
}
}
So, with this structure, the adapter's path would need to be conversations/<currentUserAuthUID>
.
(FYI this is an ember-cli project, if that makes any difference.)
It seems to be working using the following:
// adapters/conversation.js
import Ember from 'ember';
import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
pathForType: function(type) {
//get the firebase authentication data via the `Firebase` instance
//that i have injected into my app via an initializer
var authData = this.container.lookup('app:firebase').getAuth();
return Ember.String.pluralize(type) + '/' + authData.uid;
}
});