使用flask-mongoengine在MongoDB中聚合

我正在使用mongoengine聚合加入2个集合,并得到以下响应。我已经将输出转换为json对象。我也有特定的数据模型。

我有2个问题:

1)如何将commandcursor对象转换为Basequery对象,以便可以使用访问元素。容易。

2)什么是读取html模板中json的有效方法。

[
   {
      "_id":{
         "$oid":"5e94f945920ecbafa9fb61ac"
      },"user_id":{
         "$oid":"5e94f7f1920ecbafa9fb61a8"
      },"post_date":{
         "$date":1586821445182
      },"post_content":
      "num_post_likes":0,"user_closed":"","is_deleted":"","user_info":[
         {
            "_id":{
               "$oid":"5e94f7f1920ecbafa9fb61a8"
            },"first_name":"","last_name":"","email":"s,"signup_date":{

            },"user_closed":","user_type":"","friend_list":[

            ]
         }
      ]
   },{
      "_id":{
         "$oid":"5e94f85f920ecbafa9fb61ab"
      },"post_date":{
         "$date":1586821215175
      },"email":".","signup_date":{
               "$date":
            },{
      "_id":{
         "$oid":"5e94f83e920ecbafa9fb61aa"
      },"post_date":{
         "$date":1586821182246
      },{
      "_id":{
         "$oid":"5e94f806920ecbafa9fb61a9"
      },"post_date":{
         "$date":1586821126175
      },"post_content":"","num_post_likes":0,"friend_list":[

            ]
         }
      ]
   }
]
swansong13 回答:使用flask-mongoengine在MongoDB中聚合

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2442312.html

大家都在问