2
我使用Python + MongoDB中存储一些项目被称为集合中的排名数据chart
MongoDB的蟒蛇得到一个文件
{
date: date1,
region: region1,
ranking: [
{
item: bson.dbref.DBRef(db.item.find_one()),
price: current_price,
version: '1.0'
},
{
item: bson.dbref.DBRef(db.item.find_another_one()),
price: current_price,
version: '1.0'
},
.... (and the array goes on)
]
}
现在我的问题是,我想打一个历史排名中从一个数组元素位置图表为itemA
。而根据the $
positional operator,查询应该是这样的:
db.chart.find({'ranking.item': bson.dbref.DBRef('item', itemA._id)}, ['$'])
而且$
操作不起作用。
任何其他可能的解决方案?
谢谢dcrosta。你的回答给了我一个想法:我可以使用MongoDB map-reduce直接在mongodb服务器中找到位置:D – est