ground-db
ground-db copied to clipboard
ground:[email protected] can't delete documents
I can't remove documents. I get the following error...
Uncaught (in promise) TypeError: Cannot read property '_id' of undefined(…) ground.db.js:188
at http://localhost:3000/packages/ground_db.js:260:42
The pending read/write statistics confirm the failure:
READ 100% done: true
WRITE 0% done: false
If I clear the storage (which works) and insert documents again, the same error occurs when I try to remove them.
edit:
I use [email protected]
and create a unmanaged collection like new Ground.Collection('something');
@raix Could you look into pulling this and publish?
Sorry about the wait @hluz it's vaccation time :) - pr merged and 2.0.0-rc.4
is published
Thanks @JarnoLeConte
Let me know if this is still an issue in 2.0.0-rc.5
We are experiencing same problem in 2.0.0-rc6, but in different code line:
TypeError: Cannot read property '_id' of undefined(…) TypeError: Cannot read property '_id' of undefined at GroundKonetl.saveDocument (http://localhost:3000/packages/ground_db.js?hash=65466264538f340bd5903bdfa757880bdc26690c:264:26) at GroundKonetl.remove (http://localhost:3000/packages/ground_db.js?hash=65466264538f340bd5903bdfa757880bdc26690c:683:12)
The error arises when trying to remove elements from an empty collection.
So we have changed remove function on ground.db.js from line 439 and validating document before saving it as follows:
remove(selector, ...args) { // Order of saveDocument and remove call is not important // when removing a document. (why we don't need carrier for the result) const doc = this._collection.findOne(selector); doc && this.saveDocument(doc, true); return this._collection.remove(selector, ...args); }
@raix could it be included in next release? Or can I make a PR?
@paranoico you are wellcome to do a pr. I'm as always a bit low on time
Pull request done, hope have done it right #188
Thanks a lot @raix