const bookListsQuery = await modules.firestore.collection('books') .get(); const sortedObj = Object.values(bookListsQuery.docs).sort(function(a, b){ console.log('a %s b %s', a.data().order, b.data().order) return Number(a.data().order) > Number(b.data().order); }); sortedObj.forEach(function(doc){ console.log(doc.data()) }); other way object use map to array, then it sorted. const bookListsQuery = await modules.firestore.collection('books') .get(); const sortedArr = bookListsQuery.docs.map(function (doc) { // 轉換成array return doc.data() }); sortedArr.sort(function compare(a, b) { return a.order > b.order; // 升 小->大 }); sortedArr.forEach(function(data){ console.log(data.data()) }) ==========

繼續閱讀

漂亮的諧音 https://www.youtube.com/channel/UCRSmPITY7izy2F1INKMEf2g 13 小時前 中研院研究出快篩試劑, 綠媒大肆吹捧, 817們高潮連連, 綠媒說根本是大陸搶了台灣的研究功勞, 結果人家那是2月的事, 如何搶台灣3月研發出來的成果功勞? (原來中國有坐時光機穿越未來, 抄襲台灣研究成果的能力啊) 。。。 接著衛福部被抓包, 2月就核准進口大陸快篩試劑, 但衛福部辯解說進口的是抗體試劑, 中研院研發的是抗原試劑, (既然兩者快篩試劑不同, 那白痴綠媒說大陸搶了台灣研究功勞, 這是什麼毛病? 反正只要政治正確, 造謠就沒問題是嘛!?) 。。。 那中研院的快篩試劑何時可量產? 中研院長回覆說: 『此一問題「難以回答」。 做試劑不能為了趕進度忽略靈敏性與準確度。 而快篩何時人體試驗、量產, 都必須與衛福部、廠商密切合作, 時間難以預估。 「即使今年用不上, 也必須為未來的疫情做準備。」』 。。。 所以817在高潮一個, 根本還無法真正問世的東西。 台灣現在就是腦殘當道啊!

繼續閱讀

https://firebase.googleblog.com/2017/06/keep-your-promises-when-using-cloud.html?fbclid=IwAR2FuvlU2CbwjV-I75q7-WIkJyLHRYT-R3cyleEUWF3Fsq42THMCwZN6by8 const ref_p1_state = root.child(`player_states/${game_state.p1uid}`) const ref_p2_state = root.child(`player_states/${game_state.p2uid}`) const pr_update_p1 = ref_p1_state.update(update_p1) const pr_update_p2 = ref_p2_state.update(update_p2) return Promise.all([pr_update_p1, pr_update_p2]) ========== https://stackoverflow.com/questions/55430079/promise-all-does-not-wait-for-firestore-query-to-loop

繼續閱讀

https://stackoverflow.com/questions/30362733/handling-errors-in-promise-all Promise.all(state.routes.map(function(route) { return route.handler.promiseHandler().catch(function(err) { return err; }); })) .then(function(arrayOfValuesOrErrors) { // handling of my array containing values and/or errors. }) .catch(function(err) { console.log(err.message); // some coding error in handling happened }); Alternately, if you have a case where you don’t particularly care about the values of the resolved promises when there is one failure but you still want them to have run, you could do something like this which will resolve with the promises as normal when they all succeed and reject with the failed promises when any of them fail:

繼續閱讀

firestore import

使用 https://github.com/dalenguyen/firestore-backup-restore base on https://github.com/dalenguyen/firestore-import-export 能處理timestamp

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan