第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ReactiveAggregate() + collection.update() ->

ReactiveAggregate() + collection.update() ->

猛跑小豬 2021-06-22 15:04:15
反應(yīng)式聚合最初沒有錯(cuò)誤地發(fā)布到客戶端。當(dāng)來(lái)自客戶端Meteor.user的 a 更新集合時(shí),錯(cuò)誤似乎被觸發(fā)Meteor.call():updateProductFavorites = (product_key, action) => {    const { ranking } = this.props    const { product_keys } = ranking[0]    Meteor.call('Accounts.updateProductFavorites', product_key, action, (err, response) => {        if (err)            makeAlert(err.reason, 'danger', 3000)        else             this.getProductsByKeys(product_keys)        })}我已經(jīng)訂閱Meteor.user()了反應(yīng)聚合和反應(yīng)聚合:export default withTracker(() => {    const handle = Meteor.subscribe("products.RankingList")    return {        ranking: AggregatedProductRanking.find({}).fetch(),        user: Meteor.user(),        isLoading: !handle.ready() || !Meteor.user()    }})(ProductRankingList)我已經(jīng)聲明并導(dǎo)入了clientCollection雙方,正如這個(gè)答案中所建議的那樣。這是服務(wù)器端的相關(guān)代碼:const getProductRankingList = (context) => ReactiveAggregate(context, Meteor.users, [      // aggregation stages can be seen in the code snippet below    ], { clientCollection: "aggregatedProductRanking"})Meteor.methods({    'Accounts.updateProductFavorites': function(product_key, action) {         allowOrDeny(this.userId)         action = action == 'add' ? { $addToSet: { productFavorites: product_key }} : { $pull: { productFavorites: product_key }}         return Meteor.users.update({_id: this.userId}, action)     }})Meteor.publish('products.RankingList', function() {    const callback = () => this.stop()    allowOrDenySubscription(this.userId, callback)    return getProductRankingList(this)})讓我感到困惑update的Meteor.call('Accounts.updateProductFavorites')是,即使拋出了這個(gè)錯(cuò)誤,調(diào)用者仍然可以可靠地執(zhí)行。因此,對(duì)登錄的更改Meteor.user()流回客戶端,組件重新渲染。只有 ReactiveAggregate 的訂閱似乎停止工作。拋出以下錯(cuò)誤,我必須重新加載瀏覽器才能看到聚合結(jié)果的變化。(底部的完整堆棧跟蹤)Uncaught Error: Expected to find a document to change    at Object.update (collection.js:207)    at Object.store.<computed> [as update] (livedata_connection.js:310)    ...我猜這update()是由 調(diào)用ReactiveAggregate()以填充clientCollection. 但我做錯(cuò)了什么?
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

事實(shí)證明,解決方案非常簡(jiǎn)單:上述錯(cuò)誤的原因是聚合結(jié)果中缺少_id字段:


    ...

    },{

            $project: {

                _id: 0, // This will give the error.

                rankingList: 1,

                product_keys: "$product_keys.product_keys"

            }

        }

    ], { clientCollection: "aggregatedProductRanking"})

ReactiveAggregate()( meteor-reactive-aggregate )的文檔說(shuō)明該_id字段可以省略,因?yàn)樗鼘⒂蒖eactiveAggregate(). 但即使刪除了_id: 0,它也不起作用。


什么工作是這樣的:

    ...

    },{

            $project: {

                _id: "whatTheFuckIsGoingOnHere", // Calm down, bro!

                rankingList: 1,

                product_keys: "$product_keys.product_keys"

            }

        }

    ], { clientCollection: "aggregatedProductRanking"})

奇妙的反應(yīng)性聚合,只是為了在 a** 中帶來(lái)一點(diǎn)痛苦。我在github repo 中做了一個(gè)錯(cuò)誤報(bào)告


查看完整回答
反對(duì) 回復(fù) 2021-06-24
  • 1 回答
  • 0 關(guān)注
  • 149 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)