issues
.Is it possible to update individual fields instead of overwriting the whole document?
With mongoengine you can do something like
# UserME is a mongoengine Document class
user = UserME.objects.get(id=1)
user.first_name = "John"
user.last_name = "Smith"
user.save()
and the ORM will be smart enough to understand you only need to update these two fields.
Skimming through the code it seems the way to do this with mongomantic would be
# UserMM is a mongomantic MongoDBModel class
user = UserMM.objects.get(id=1)
user.first_name = "John"
user.last_name = "Smith"
user = UserRepository.save(user)
The main concern I have is that it looks like the repository is creating a new document and overwriting the existing one. This can potentially be dangerous as any fields not in the model would disappear, and if you have multiple concurrent write operations to the DB only the last one would "stick".
I've been working with a pattern surprisingly similar to what you're building and came across the issue I mentioned above on my own code. So I started researching if other's have found a solution and that's when I came across this repo. My thinking is we need some kind of stack to store the changes until the save()
call. But I haven't found a decent way to do this with pydantic.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too