查找全部:

db.collectionName.find()
根据字段查找(精确匹配,大小写敏感):
db.collectionName.find( { "cuisine": "Italian"} )
或的关系:
db.restaurants.find({ $or: [ { "cuisine": "Italian" }, { "address.zipcode": "10075" } ] })
AND关系:
db.restaurants.find({ "cuisine": "Italian", "address.zipcode": "10075" })
排序:
db.restaurants.find().sort( { "borough": 1, "address.zipcode": 1 } )
正则表达式:
# 1.包含:
db.collectionname.find({'files':{'$regex':'File'}})
# 2.开头,结尾:
db.collectionname.find({'files':{'$regex':'^File$'}})
# 3.忽略大小写:
db.collectionname.find({'files':{'$regex':'^file','$options':'i'}})
# 或者是:
import re
regx = re.compile("^name", re.IGNORECASE)
db.collectionname.find_one({"files": regx})

 

转载自:https://blog.csdn.net/zhangruixia0108/article/details/49836829

相关文章:

  • 2022-02-08
  • 2021-09-07
  • 2021-12-27
  • 2022-12-23
  • 2021-06-08
  • 2022-02-08
  • 2022-12-23
  • 2021-08-12
猜你喜欢
  • 2021-10-29
  • 2021-04-30
  • 2022-02-24
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案