Fixes for a) incorrect access to collection and b) try shorter index name in case auto-generated index name is too long

This PR is addressing two issues. The first one is a critical one.

The line 191 in base.py is referring to self.connection.database.collection_names(). This line was resulting in the creation of a new database named 'database'. It should have been 'self.database.collection_names()'

Second fix is not severe. In case of long field names with an index name, the auto-generated index name can exceed the limits imposed by mongo. In such case, the code will try to use a randomly generated index name.