2017-04-17 55 views

回答

1

查詢中沒有用於服務器端時間戳的內置運算符。您必須使用客戶端時間戳和known latency to the server構建某些內容,或者先閱讀server-side timestamp

+0

我們可以使用雲功能和數據庫事件嗎?是否有明顯的延遲。哪種方法最好? @坦率-VAN-puffelen –

1

您可以在Firebase中使用客戶端時間。

OR

使用雲功能的火力地堡,讓您運行移動後端代碼自動響應由火力地堡的功能在你的情況 databas事件

見觸發事件:https://firebase.google.com/docs/functions/database-events

如:在/ records/{pushId}/servertime中偵聽/ records/{pushId} /寫入時間

exports.makeUppercase = functions.database.ref('/records/{pushId}/time') 
    .onWrite(event => { 

     var date = new Date(); 
     var current_hour = date.getHours(); 
return event.data.ref.parent.child('servertime').set(current_hour); 
} 

另請參閱:https://www.youtube.com/watch?v=7E13ZBCyKT0