Reputation: 4339
I am getting this error:
Error: cache_for must be an integer or float.
That is becouse of this line:
self.db.table_name.create_index("url", {"unique": True})
But i don't know why, what is wrong here?
Upvotes: 2
Views: 1429
Reputation: 61225
You are doing it wrong the right syntax is:
self.db.table_name.create_index("url", unique=True)
By default this create a single key ascending index and is equivalent to
self.db.table_name.create_index([("url", pymongo.ASCENDING)], unique=True)
To create a descending index you need to explicitly specify it:
self.db.table_name.create_index([("url", pymongo.DESCENDING)], unique=True)
More info in the documentation
You can also create more indexes with create_indexes(indexes)
Upvotes: 4