Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的查询
db.Usage.find({'Usage': "",'Rating': "", 'Average Ratings': ""}).count() 1500
我想删除此查询的最后 500 个条目。他们是删除最后 500 个条目的一种方法,还是我必须立即删除与此查询匹配的所有文档,然后再次插入有效的 1000 个文档
提前致谢
it = db.Usage.find({'Usage': "",'Rating': "", 'Average Ratings': ""})[1001:1500] to_rem = [] for doc in iter: to_rem.append( doc['_id'] ) try: db.Usage.remove( {'_id' :{ '$in': to_rem } }) except: print "Unexpected error:", sys.exc_info()[0]