我有一个Document对象列表,它在数据库中有一个现有的id
。我已经更新了它们,现在我想将它们全部放入现有ID的数据库中。有没有办法在一个查询中执行此操作?
一个例子
def _update_podcast(podcast):
data = fetch_podcast(podcast.url)
podcast.url = data.url
#... more similar updates to podcast
def update_podcasts()
podcasts = Podcast.objects(last_updated__lte=datetime.datetime.now() - datetime.timedelta(seconds=3600))
for p in podcasts:
_update_podcast(p)
# At this point, every podcast in podcasts is updated.
# Now how do I save the modified podcasts with a single query?