Search code examples
mongodbmorphia

MongoDB + Morphia -> Refresh Datastore


I am new to MongoDB so please bear with me. I have a MongoDB that can be updated from two places - from an admin panel in PHP and from a deployed server using Morphia. My question is that if MongoDB is updated from the admin panel after the datastore is created using Morphia, then how do I get the updated values from the db into the data store?(I have tried to search for this but all queries just point to how to update the data store in Morphia. It could be that I am formatting the query wrong.) Does it automatically get updated in the datastore? or Do I have to keep discarding the existing datastore and create a new one?In that case the question arises that what would be the best way to do that? Also, how would saves from Morphia and updates from the admin panel be handled so that there is no conflict?


Solution

  • The Datastore doesn't cache anything. It's simply a conduit through which to execute database operations. If you query very Morphia after updating from your PHP app, you'll see your new data just fine. You don't need to create a new Datastore each time.