def on_commit(self, dr, row): path = dr.account_path if row._id: row.save() else: save_model_with_autoincremented_id(row, 'acc') self.account_store[path][0] = row.id self.add_new_account(path)
def test_auto_increment_on_model(db): class Doc(Document): __collection__ = db.collection1 Doc(document={'_id':20}).save() d = Doc() dd = save_model_with_autoincremented_id(d) assert dd is d assert d.id == 21