locallydb icon indicating copy to clipboard operation
locallydb copied to clipboard

upsert isn't work correctly

Open oliseviche opened this issue 9 years ago • 3 comments

Current upsert method contains the following code:

if (check.length > 0) {
.. do update...
}
else {
.. do insert...
}

But 'check' variable is an object, not an array, contained 'items' property within self with length property. May be there are cases when that statement isn't true, but currently 'upsert' is broken.

oliseviche avatar Feb 11 '16 06:02 oliseviche

the value of checkis returned by this.where that always returns a List, check where implementation at list.coffee or list.js

btwael avatar Feb 11 '16 12:02 btwael

All is good in list.js Things bad in collection.js, where check variable is assigned to a List, but in "if" statments it is evaluated not on check.items.length, but on check.length itself.

oliseviche avatar Feb 11 '16 13:02 oliseviche

You're right :+1: gonna fix this one ;)

btwael avatar Feb 12 '16 02:02 btwael