Kirill
Kirill

Reputation: 85

PyMongo NoneType error when I try to use None as null for query

Hi guys and sorry for my bad english. I am using pymongo for querying to mongodb. so when i try to use None as null in my query, I get error: NoneType object is not subscriptable.

Here is an example:

db.collection.find_one({'name': "Nick", 'age': None})
# 'NoneType' object is not subscriptable error

Can you help me to solve this problem, please?

Upvotes: 1

Views: 1780

Answers (1)

Tanu
Tanu

Reputation: 1563

Although, not tried but try passing null instead of None:

db.collection.find_one({'name': "Nick", 'age': null})

Upvotes: 1

Related Questions