Query methods using greater than, less than, greater than or equal to and less than or equal to in pymongo

From , 5 Years ago, written in Python, viewed 213 times.
URL https://pastebin.vip/view/853bb47a
  1. from bson.objectid import ObjectId
  2. import pymongo
  3.  
  4. #查询代码
  5. #连接本机mongodb
  6. conn=pymongo.Connection()
  7. #指定数据库
  8. db = conn.books
  9. #指定collection
  10. collection = db.book
  11. #大于
  12. collection.find({'_id':{'$gt':ObjectId('51f6126139ecbb1db4a75667')}})
  13. #大于等于
  14. collection.find({'_id':{'$gte':ObjectId('51f6126139ecbb1db4a75667')}})
  15. #小于
  16. collection.find({'_id':{'$lt':ObjectId('51f6126139ecbb1db4a75667')}})
  17. #小于等于
  18. collection.find({'_id':{'$lte':ObjectId('51f6126139ecbb1db4a75667')}})
  19. #//python/8231

Reply to "Query methods using greater than, less than, greater than or equal to and less than or equal to in pymongo"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website