[{"data":1,"prerenderedAt":317},["ShallowReactive",2],{"blog-\u002Fblog\u002Fwechat_mini_program_lookup_join_table_query":3},{"id":4,"title":5,"body":6,"category":304,"cover":305,"csdn":305,"date":306,"description":5,"draft":307,"extension":308,"meta":309,"navigation":310,"path":311,"seo":312,"stem":313,"tags":314,"updated":305,"__hash__":316},"blog\u002Fblog\u002Fwechat_mini_program_lookup_join_table_query.md","微信小程序 lookup 联表查询",{"type":7,"value":8,"toc":297},"minimark",[9,14,22,32,35,41,47,55,63,65,68,201,211,213,217,221,227,233,235,239,243,249,256,258,262,268,293],[10,11,13],"h2",{"id":12},"微信小程序-云开发","微信小程序 云开发",[15,16,17,21],"p",{},[18,19,20],"code",{},"store"," 商品集合",[23,24,29],"pre",{"className":25,"code":27,"language":28},[26],"language-text","\n_id: 'a8831daa5fef02f50153146e5902c2aa',\nopenid: 'oMlDj5JiYiwxyBJm-d4JFY-Ov-LM', \u002F\u002F 发布商品者 openid\ntitle: '小米手电筒',\nliulan: 29,\nprice: 19.9,\nimgUrl: 'xxxxxxxxxxxxxxxx',\ntime: 1609499381638,\nshenhe: true,\n\n","text",[18,30,27],{"__ignoreMap":31},"",[33,34],"hr",{},[15,36,37,40],{},[18,38,39],{},"fav"," 收藏集合",[23,42,45],{"className":43,"code":44,"language":28},[26],"\n_id: 'b45a21d55ff155e2036603d6218fa777',\n_openid: 'oMlDj5JiYiwxyBJm-d4JFY-Ov-LM',    \u002F\u002F 收藏者 openid\nfav_id: 'a8831daa5fef02f50153146e5902c2a1'  \u002F\u002F 收藏的商品 _id\n\n",[18,46,44],{"__ignoreMap":31},[15,48,49,51,52,54],{},[18,50,39],{}," 集合记录数量 = ",[18,53,20],{}," 商品集合记录数量 * 所有商品总收藏数量",[15,56,57,58,62],{},"会产生 ",[59,60,61],"strong",{},"超级多"," 的记录",[33,64],{},[15,66,67],{},"联表查询 （我收藏的.wxml）云函数代码",[23,69,73],{"className":70,"code":71,"language":72,"meta":31,"style":31},"language-js shiki shiki-themes github-light","function getfavlist(event, context) {\n  return new Promise(function (resolve, reject) {\n    db.collection(\"fav\")\n      .aggregate()\n      .lookup({\n        from: \"store\",\n        localField: \"fav_id\",\n        foreignField: \"_id\",\n        as: \"storedetail\",\n      })\n      .match({\n        _openid: event.userInfo.openId,\n      })\n      .end()\n      .then((res) => {\n        console.log(res);\n        resolve(res);\n      })\n      .catch((err) => console.error(err));\n  });\n}\n","js",[18,74,75,83,89,95,101,107,113,119,125,131,137,143,149,154,160,166,172,178,183,189,195],{"__ignoreMap":31},[76,77,80],"span",{"class":78,"line":79},"line",1,[76,81,82],{},"function getfavlist(event, context) {\n",[76,84,86],{"class":78,"line":85},2,[76,87,88],{},"  return new Promise(function (resolve, reject) {\n",[76,90,92],{"class":78,"line":91},3,[76,93,94],{},"    db.collection(\"fav\")\n",[76,96,98],{"class":78,"line":97},4,[76,99,100],{},"      .aggregate()\n",[76,102,104],{"class":78,"line":103},5,[76,105,106],{},"      .lookup({\n",[76,108,110],{"class":78,"line":109},6,[76,111,112],{},"        from: \"store\",\n",[76,114,116],{"class":78,"line":115},7,[76,117,118],{},"        localField: \"fav_id\",\n",[76,120,122],{"class":78,"line":121},8,[76,123,124],{},"        foreignField: \"_id\",\n",[76,126,128],{"class":78,"line":127},9,[76,129,130],{},"        as: \"storedetail\",\n",[76,132,134],{"class":78,"line":133},10,[76,135,136],{},"      })\n",[76,138,140],{"class":78,"line":139},11,[76,141,142],{},"      .match({\n",[76,144,146],{"class":78,"line":145},12,[76,147,148],{},"        _openid: event.userInfo.openId,\n",[76,150,152],{"class":78,"line":151},13,[76,153,136],{},[76,155,157],{"class":78,"line":156},14,[76,158,159],{},"      .end()\n",[76,161,163],{"class":78,"line":162},15,[76,164,165],{},"      .then((res) => {\n",[76,167,169],{"class":78,"line":168},16,[76,170,171],{},"        console.log(res);\n",[76,173,175],{"class":78,"line":174},17,[76,176,177],{},"        resolve(res);\n",[76,179,181],{"class":78,"line":180},18,[76,182,136],{},[76,184,186],{"class":78,"line":185},19,[76,187,188],{},"      .catch((err) => console.error(err));\n",[76,190,192],{"class":78,"line":191},20,[76,193,194],{},"  });\n",[76,196,198],{"class":78,"line":197},21,[76,199,200],{},"}\n",[15,202,203,208],{},[204,205],"img",{"alt":206,"src":207},"在这里插入图片描述","https:\u002F\u002Fpub-5ec96507162a4f0a8e713a916117c9f4.r2.dev\u002Fblog\u002F95d106358b68508672e826d5a9cbd692.png#pic_center",[204,209],{"alt":206,"src":210},"https:\u002F\u002Fpub-5ec96507162a4f0a8e713a916117c9f4.r2.dev\u002Fblog\u002F1479bde0cee2c817298451fa3c704942.png#pic_center",[33,212],{},[10,214,216],{"id":215},"感觉把-微信小程序-云开发-文档型数据库-用成了关系型数据库","感觉把 微信小程序 云开发 文档型数据库 用成了关系型数据库",[10,218,220],{"id":219},"还可以给-store-商品集合-下的所有记录-新增-fav_openid-字段-一个数组存储-收藏者的-openid","还可以给 store 商品集合 下的所有记录 新增 fav_openid 字段 （一个数组存储 收藏者的 openid)",[23,222,225],{"className":223,"code":224,"language":28},[26],"\n_id: 'a8831daa5fef02f50153146e5902c2aa',\nopenid: 'oMlDj5JiYiwxyBJm-d4JFY-Ov-LM', \u002F\u002F 发布商品者 openid\nfav_openid: ['小明的 openid', 'Tom 的 openid', '马保国的 openid'],\ntitle: '小米手电筒',\nliulan: 29,\nprice: 19.9,\nimgUrl: 'xxxxxxxxxxxxxxxx',\ntime: 1609499381638,\nshenhe: true,\n\n",[18,226,224],{"__ignoreMap":31},[15,228,229,230,232],{},"这样看上去 ",[18,231,20],{}," 商品集合存储空间会比较大？",[33,234],{},[10,236,238],{"id":237},"试试这样","试试这样？",[15,240,241,40],{},[18,242,39],{},[23,244,247],{"className":245,"code":246,"language":28},[26],"\n_id: 'b45a21d55ff155e2036603d6218fa777',\n_openid: 'oMlDj5JiYiwxyBJm-d4JFY-Ov-LM',                                    \u002F\u002F 收藏者 openid\nfav_openid: ['小明的 openid', 'Tom 的 openid', '马保国的 openid'],\n\n",[18,248,246],{"__ignoreMap":31},[15,250,251,51,253,255],{},[18,252,39],{},[18,254,20],{}," 商品集合记录数量",[33,257],{},[10,259,261],{"id":260},"推荐一下刚上线的-app-熊猫小账本","推荐一下刚上线的 App 熊猫小账本。",[15,263,264,267],{},[18,265,266],{},"熊猫小账本"," 一个简洁的记账 App，用于记录日常消费开支收入，使用 iCloud 保存同步数据。",[269,270,271,275,278,281,284,287,290],"ul",{},[272,273,274],"li",{},"支持备注，自定义时间偶尔忘记记账也没关系。",[272,276,277],{},"搜索历史记账，支持分类、金额、备注。",[272,279,280],{},"启动时需要面容\u002F指纹验证，保护个人隐私。",[272,282,283],{},"支持自定义分类功能，自由添加修改分类。",[272,285,286],{},"统计图表，支出收入一目了然。",[272,288,289],{},"每天提醒记账，不会有其他推送。",[272,291,292],{},"桌面锁屏小组件开发中。。。",[294,295,296],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":31,"searchDepth":85,"depth":85,"links":298},[299,300,301,302,303],{"id":12,"depth":85,"text":13},{"id":215,"depth":85,"text":216},{"id":219,"depth":85,"text":220},{"id":237,"depth":85,"text":238},{"id":260,"depth":85,"text":261},"前端",null,"2021-01-06",false,"md",{},true,"\u002Fblog\u002Fwechat_mini_program_lookup_join_table_query",{"title":5,"description":5},"blog\u002Fwechat_mini_program_lookup_join_table_query",[315],"微信小程序","GKk0MlMl4gRnH3fDKg8_YgMTcLV7qgODbyMbcvHRVLk",1783011523543]