2014-10-11 49 views
0

有什麼方法可以將用戶身份驗證uid包含在模型適配器的路徑中?例如,假設你有一個聊天應用,以及conversation模型來表示兩個用戶,在數據存儲這樣的事情之間的私人郵件會話:基於身份驗證標識的動態適配器pathForType

{ 
    "conversations": { 
     "<userAuthUID>": { 
      "convo1": {...}, 
      "convo2": {...}, 
      ... 
     }, 
     "<anotherUserAuthUID>": { 
      ... 
     } 
    } 
} 

因此,通過這種結構,適配器的路徑將需要是conversations/<currentUserAuthUID>

(FYI這是灰燼,CLI的項目,如果有什麼差別。)

回答

0

這似乎可以利用工作如下:

// 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; 
    } 
});