ground-db icon indicating copy to clipboard operation
ground-db copied to clipboard

ground:[email protected] can't delete documents

Open JarnoLeConte opened this issue 8 years ago • 6 comments

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');

JarnoLeConte avatar Jun 15 '16 22:06 JarnoLeConte

@raix Could you look into pulling this and publish?

hluz avatar Jul 13 '16 12:07 hluz

Sorry about the wait @hluz it's vaccation time :) - pr merged and 2.0.0-rc.4 is published Thanks @JarnoLeConte

raix avatar Jul 13 '16 14:07 raix

Let me know if this is still an issue in 2.0.0-rc.5

raix avatar Aug 24 '16 20:08 raix

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 avatar Nov 20 '16 03:11 paranoico

@paranoico you are wellcome to do a pr. I'm as always a bit low on time

raix avatar Nov 20 '16 22:11 raix

Pull request done, hope have done it right #188

Thanks a lot @raix

paranoico avatar Nov 21 '16 02:11 paranoico