Reputation: 332
I'm currently editing existing documents in my ravenDB instance. The main issue i'm facing is that i get no errors but no changes are saved. I'm using the following code :
#in init method
self.store = document_store.documentstore(url=self.dbURL, database=self.dbInUse)
self.store.initialize()
def someMethodToSaveData(self, id, newTextField="")
with self.store.open_session() as session:
doc = session.load(id)
doc.newTextField=newTextField
session.store(doc,id)
session.save_changes()
thanks
edit: added session.save_changes() in this code. testing, but i have that line in another project and I'm facing the same issue with it.
Upvotes: 0
Views: 105
Reputation: 2796
I think you will have to call the method session.save_changes() so that the the database transaction completes:
#in init method
self.store = document_store.documentstore(url=self.dbURL, database=self.dbInUse)
self.store.initialize()
def someMethodToSaveData(self, id, newTextField="")
with self.store.open_session() as session:
doc = session.load(id)
doc.newTextField=newTextField
session.store(doc,id)
session.save_changes() # this call is important
I found this information in the offical RavenDB documentation:
Upvotes: 2