2

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?

1 Answer 1

4

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.