ravenDB + python 不保存

ravenDB + python not saving

我目前正在编辑我的 ravenDB 实例中的现有文档。 我面临的主要问题是我没有收到任何错误,但没有保存任何更改。 我正在使用以下代码:

    #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()

谢谢

编辑:在此代码中添加了 session.save_changes()。测试,但我在另一个项目中有该行,我也面临同样的问题。

我认为您必须调用方法 session.save_changes() 以便数据库事务完成:

 #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

我在官方 RavenDB documentation:

找到了这个信息