[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
I have an EntityStore with stores Conversation class instances. When using upsert an already existing entity is updated correctly and is returned as a Conversation instance. However when a new instance is upserted and fetched with a getAll query it is returned as a regular Object, not a Conversation object. Thus all related Conversation functions are gone.
I am upserting like this: store.upsert(conversation.getId(), conversation)
upserting a new instance should store the class instance, not a default object
For bug reports please provide the STEPS TO REPRODUCE and if possible a MINIMAL DEMO of the problem via
https://stackblitz.com or similar (you can use this template as a starting point: https://stackblitz.com/github/NetanelBasal/akita-issue-seed).
Angular version: 7.1.4
Browser:
- [X] Chrome (desktop) version 73.0.3683.86
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
However when a new instance is upserted
Akita can't know that this is a class-based object. When using set() or add() you're responsible for doing it.
So you mean I need to use add() instead of upsert() in my case?
The idea then is to check if the object already exists in the store, if yes, use upsert(), if no use add(). Correct?
I will add a third options parameter that you can pass the base class.
If that would make it work that would be awesome!
store.upsert(1, { title: 'new title' }, { baseClass: Todo });
Most helpful comment
store.upsert(1, { title: 'new title' }, { baseClass: Todo });