mongodb 里面 $where 这样的语句在 Python 代码里面怎么写?

2018-12-30 15:09:59 +08:00
 woaicheny

db.book.find( { $where: function() { ... return this._id % 100 == 0 ... } } ) 这样的 shell 在 python 里面应该怎么写?

1995 次点击
所在节点    Python
3 条回复
janxin
2018-12-30 15:15:08 +08:00
传字符串...
“$where ”: "blablabla"
susecjh
2018-12-30 18:54:40 +08:00
你只要记住传 dict 进去就知道怎么写了
woaicheny
2018-12-30 21:37:53 +08:00
@susecjh 但是我连最简单的这么写都是报错额? data = db.book.find({"$where":"lambda x:x"})
print(data[0])

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/522542

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX