我在 reddit 上抓取一些链接并将结果存储在 MongoDB 集合中。这是我的 Python 脚本中唯一存储数据的行:
reddit_links_collection.update(
{'_id': id}, # query
{ # update rules
'$set': {
'title': title,
'url': url
},
'$push': {'scores': (current_time, score)},
'$push': {'ups': (current_time, ups)},
'$push': {'downs': (current_time, downs)}
},
upsert=True # insert new if no one matches the query
)
我想将值推送到所有三个数组,但只'downs'
存储在我的数据库中。我错过了什么?
我是 MongoDB 的新手,但是已经阅读过update
并且push
无法弄清楚我做错了什么。