txmongo
txmongo copied to clipboard
txmongo list of collections not returned
txmongo dosen't return list of all collections.Inserts and deletes works just fine.Below is the code that is being used.
from txmongo.connection import ConnectionPool
from twisted.internet import defer, reactor
import time
@defer.inlineCallbacks
def mongoHost():
mongodb_uri = "mongodb://%s:%s" % ('127.0.0.1', '27017')
mongo = yield ConnectionPool(mongodb_uri)
defer.returnValue(mongo)
@defer.inlineCallbacks
def query_to_db():
mongo = yield mongoHost()
db = mongo['clients']
coll = yield db.collection_names() # <------------------dosen't works!
# coll = yield db.facebook.find({}) <------------------works !
print coll
if __name__ == '__main__':
reactor.callLater(1, query_to_db)
reactor.run()
Oops, you are right, it seems to be broken on MongoDB 3.x
As a workaround you can probably try yield db.command("listCollections")
@IlyaSkriblovsky thanks :)
Nice find, time for another component test. :)
@IlyaSkriblovsky @psi29a it works in MongoDB 3.0.12. verified
@ashishRay12 what version are you using?
@anekix i am using MongoDB 3.2.14.
collection_names()
is using system.namespaces
special collection that was deprecated in 3.0 and probably removed in 3.2: https://docs.mongodb.com/manual/reference/system-collections/#