Movies.find( { "cast": "Salma Hayek" } ).count()

I get this error on this ‘find’ command:
/opt/anaconda3/anaconda3/lib/python3.7/site-packages/ DeprecationWarning: count is deprecated. Use Collection.count_documents instead.
“”"Entry point for launching an IPython kernel.

Any help would be appreciated.

The message says that count is deprecated and to use count_documents. With google I found the following documentation and count_documents is somewhere in there.

Error messages are your friend, you should trust them.

10x you a lot !
when I replace ‘count’ --> ‘count_document’, I get this error

AttributeError Traceback (most recent call last)
----> 1 movies.find( { “cast”: “Salma Hayek” } ).count_documents()

AttributeError: ‘Cursor’ object has no attribute 'count_documents’

That is not the syntax from the link I sent.

thank you, I change my Jupyter notebook according

movies.find( { “cast”: “Salma Hayek” } ).count()

this is the syntax in jupyter notebook

We know the count method is deprecated. This course was in development prior to that change, and we’ll be updating the notebook accordingly.

1 Like