I'm currently using MongoDB Atlas, and I'm trying to see whether I can access data via Eve locally before testing on the cloud. I have the following in settings.py:
MONGO_DBNAME = "Nintendo"
MONGO_URI = "mongodb+srv://user:password@xyz.gcp.mongodb.net/test?retryWrites=true&w=majority"
Games = {
'schema': {
"Name": {'type': 'string'},
"Year": {'type': 'number'}
}
}
DOMAIN = {
"Games": Games
}
and I have the following demo data under the collection "Games":
{"Name":"Legend of Zelda: Breath of the Wild","Year":2017}
{"Name":"Luigi's Mansion","Year":2001}
When I query for the demo data using http://localhost:1234/Games, I get no matching documents, when I expect there to be two. Specifically, I get the following response:
<resource href="Games" title="Games">
<link rel="parent" href="/" title="home"/>
<_meta>
<max_results>25</max_results>
<page>1</page>
<total>0</total>
</_meta>
</resource>
I've checked that the URI is correct by connecting to MongoDB Atlas using the PyMongo driver, and I've also checked that the DB and Collection names are correct. Any idea what is happening in this situation? Thank you!
I figured out through the pymongo URI parser, that the URI was trying to access the test DB, instead of the Games DB. I believe this happens since Eve relies on Flask-Pymongo. I just changed the URI link above from "mongodb+srv://user:password@xyz.gcp.mongodb.net/test?retryWrites=true&w=majority" to "mongodb+srv://user:password@xyz.gcp.mongodb.net/Games?retryWrites=true&w=majority". And now it works!