MongoDB 集合名称带有 pymongo 前缀
我想要单个 MongoDB 数据库上的单独环境。
如何动态为我的集合添加前缀?
例如,MongoClient 上有一个选项:
client = pymongo.MongoClient(MONGO_URI, prefix="devenv1")
db = client[DB_NAME]
db.users.find() # -> would transparently run db.devenv1_users.find()
I want separate environments on a single MongoDB database.
How can I prefix my collections dynamically?
For example, something with an option on MongoClient:
client = pymongo.MongoClient(MONGO_URI, prefix="devenv1")
db = client[DB_NAME]
db.users.find() # -> would transparently run db.devenv1_users.find()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
is 同义
与and
:所以现在您可以通过变量控制集合名称并将其设置为您喜欢的任何前缀。
is synonymous with
and also:
So now you can control the collection name through a variable and set it to whatever prefix you like.