0
0

Pymongo count()について

Posted at

Pymongoのcount()

いろいろなサイトを参考にPymongoを触っていたところ、以下のコードが動作しない。

device = mycol.find({'name' : 'Moore'}count()

これを実行すると、Cursorにはcount()などという関数は存在しないと言われる。

count_document()という存在

どうやらアップデートでMongo DBからcount()は消失し、count_document()が生まれたらしい。

device = mycol.count_documents({'name' : 'Moore'})

そもそも記法としてfind()の後にカウントすることなかったようですが、これで解決。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0