How create a new array field with the aggregate framework

前端 未结 4 2046
礼貌的吻别
礼貌的吻别 2021-02-15 15:51

I\'m starting to use mongoDb and I\'m stuck with a simple use case.

Let\'s say I\'ve got a collection \'aCollection\' with entries such as this:



        
4条回答
  •  [愿得一人]
    2021-02-15 16:26

    Ok, so first of all let us understand what aggregation framework does. It only queries the available data and returns the result. It does NOT modify the original documents! That is why the second piece of code that you have written performs an aggregation, does a projection and displays some result of a successful run of an aggregate query.

    To make the changes that you are trying to do, you can either try the 'quick and dirty' approach of Martin Konecny's answer or you can modify the code for uploading the data and perform a fresh upload.

    Since I see that instead of using decimal point you are using comma in the lat/long values I would say that if later on in time you will try to query this geo-spatial data, you better upload it again properly.

提交回复
热议问题