【发布时间】:2020-06-02 22:23:14
【问题描述】:
MongoDB Stitch 3rd Party Services 如何返回 JSON 数组对象?我的回报是显示带有 $(美元符号)的 EJSON。有人可以帮助我吗?
return mycollection.findOne({"_id": BSON.ObjectId(id)});
响应例如:成本:{$numberDouble: "65"}
我需要例如:成本:65
【问题讨论】:
MongoDB Stitch 3rd Party Services 如何返回 JSON 数组对象?我的回报是显示带有 $(美元符号)的 EJSON。有人可以帮助我吗?
return mycollection.findOne({"_id": BSON.ObjectId(id)});
响应例如:成本:{$numberDouble: "65"}
我需要例如:成本:65
【问题讨论】:
见: https://docs.mongodb.com/realm/mongodb/actions/collection.find/
创建一个数组试试:
return mycollection.find({"_id": BSON.ObjectId(id)}).toArray();
要解决 numberDouble 的问题,请参阅: MongoDB Stitch returns data as $NumberDouble instead of the number itself
【讨论】: