Comparing version 8.7.5 to 8.8.0
@@ -570,3 +570,3 @@ 'use strict'; | ||
return internals.special('append', value, options); // { single: false } | ||
return internals.special('append', value, options); // { single: false, create: false } | ||
} | ||
@@ -573,0 +573,0 @@ |
@@ -40,14 +40,10 @@ 'use strict'; | ||
let update = null; | ||
let update = item; | ||
if (without.length) { | ||
update = update.without(without); | ||
} | ||
if (wrapped) { | ||
if (without.length) { | ||
update = item.without(without).merge(wrapped); | ||
} | ||
else { | ||
update = item.merge(wrapped); | ||
} | ||
update = update.merge(wrapped); | ||
} | ||
else { | ||
update = item.without(without); | ||
} | ||
@@ -91,8 +87,20 @@ return RethinkDB.branch(RethinkDB.eq(item, null), RethinkDB.error('No document found'), update); | ||
if (changes.type === 'append') { | ||
if (changes.flags.single || !Array.isArray(changes.value)) { | ||
return row.append(changes.value); | ||
if (changes.flags.single || | ||
!Array.isArray(changes.value)) { | ||
row = row.append(changes.value); | ||
} | ||
else { | ||
for (let i = 0; i < changes.value.length; ++i) { | ||
row = row.append(changes.value[i]); | ||
} | ||
} | ||
for (let i = 0; i < changes.value.length; ++i) { | ||
row = row.append(changes.value[i]); | ||
if (changes.flags.create) { | ||
let check = item; | ||
for (let i = 0; i < path.length - 1; ++i) { | ||
check = check(path[i]); | ||
} | ||
return RethinkDB.branch(check.hasFields(path[path.length - 1]), row, [changes.value]); | ||
} | ||
@@ -116,22 +124,22 @@ | ||
const keys = Object.keys(changes); | ||
for (let i = 0; i < keys.length; ++i) { | ||
const key = keys[i]; | ||
for (const key in changes) { | ||
const value = changes[key]; | ||
const wrapped = internals.wrap(value, without, item, path.concat(key)); | ||
if (wrapped !== value) { | ||
if (ref === changes) { | ||
ref = Object.assign({}, changes); // Shallow clone before making changes | ||
} | ||
if (wrapped === value) { | ||
continue; | ||
} | ||
if (wrapped === undefined) { | ||
delete ref[key]; | ||
} | ||
else { | ||
ref[key] = wrapped; | ||
} | ||
if (ref === changes) { | ||
ref = Object.assign({}, changes); // Shallow clone before making changes | ||
} | ||
if (wrapped === undefined) { | ||
delete ref[key]; | ||
} | ||
else { | ||
ref[key] = wrapped; | ||
} | ||
} | ||
if (keys.length && | ||
if (Object.keys(changes).length && | ||
!Object.keys(ref).length && | ||
@@ -138,0 +146,0 @@ !Array.isArray(ref)) { |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "8.7.5", | ||
"version": "8.8.0", | ||
"repository": "git://github.com/hueniverse/penseur", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74930
1858