Hi Anvilistas,
I want to create a server module to handle data access to a MongoDB Atlas Cluster instance.
I have defined the documents as classes in a client module, which I import in the servermodule.
I’m able to connect using following code (in the client module):
HOST = ‘mongodb+srv://username:password@cluster0.k1u9ph2.mongodb.net/?retryWrites=true&w=majority’
DBASE = ‘Cluster0’
connect(DBASE,host=HOST)
print (‘Connected to {} : {}’.format(DBASE, HOST))
This seems to work.
What I’ve tried and what’s not working:
Next i’m trying to do a query to a document in MongoDB Atlas and there I receive a timeout.
Please look at the servermodule code:
@anvil.server.callable
def m_get_personas(**query):
session = get_session(‘m_get_personas’)
result = []
personas = Personas.objects(**query) # Personas is a Document class defined in the client module
(which is imported) and here the code hangs…
for persona in personas:
result.append({'name': persona.name,
'is_person': persona.is_person,
})
return result
Anyone experienced something similar ?
Any solution ?
Thanks
Paul