Comparing version 1.0.243 to 1.0.244
@@ -89,3 +89,3 @@ "use strict"; | ||
// a change in one place changes both places | ||
let record_to_nest = i === 0 ? record : Object.assign({}, record); | ||
let record_to_nest = i === higher_records.length - 1 ? record : Object.assign({}, record); | ||
// add this record to the index so we can nest other stuff on it. We must do this once per higher record, | ||
@@ -95,3 +95,3 @@ // since we are making shallow copies for each higher record | ||
nester_set(higher_record, record_to_nest, set_field, array_mode); | ||
apply_nester_modifications(nester_modification, record); | ||
apply_nester_modifications(nester_modification, record_to_nest); | ||
}); | ||
@@ -98,0 +98,0 @@ }); |
@@ -175,5 +175,9 @@ "use strict"; | ||
], | ||
[['variants', 0, 'products', 0], [{ id: 1 }]], | ||
[['variants', 0, 'products', 0], [{ id: 1, title: 'my product' }]], | ||
[ | ||
['variants', 0, 'products', 0, 'images', 0], | ||
[{ variant_id: 1, url: 'test' }], | ||
], | ||
]; | ||
const edges = [null, ['product_id', 'id']]; | ||
const edges = [null, ['product_id', 'id'], ['id', 'variant_id']]; | ||
const goal = { | ||
@@ -186,3 +190,9 @@ variants: [ | ||
{ | ||
id: 1, | ||
title: 'my product', | ||
images: [ | ||
{ | ||
variant_id: 1, | ||
url: 'test', | ||
}, | ||
], | ||
}, | ||
@@ -196,3 +206,9 @@ ], | ||
{ | ||
id: 1, | ||
title: 'my product', | ||
images: [ | ||
{ | ||
variant_id: 1, | ||
url: 'test', | ||
}, | ||
], | ||
}, | ||
@@ -203,3 +219,8 @@ ], | ||
}; | ||
let result = (0, nester_1.nester)(data, edges, []); | ||
// deleting the product id makes sure the field is not deleted before adding | ||
// the copy to the index | ||
let result = (0, nester_1.nester)(data, edges, [ | ||
{ additions: [], deletions: [] }, | ||
{ additions: [], deletions: [{ field: 'id' }] }, | ||
]); | ||
(0, chai_1.expect)(result).to.deep.equal(goal); | ||
@@ -206,0 +227,0 @@ }); |
{ | ||
"name": "orma", | ||
"version": "1.0.243", | ||
"version": "1.0.244", | ||
"description": "A declarative relational syncronous orm", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -117,3 +117,4 @@ import { get_higher_path } from '../mutate/helpers/mutate_helpers' | ||
// a change in one place changes both places | ||
let record_to_nest = i === 0 ? record : { ...record } | ||
let record_to_nest = | ||
i === higher_records.length - 1 ? record : { ...record } | ||
@@ -124,3 +125,3 @@ // add this record to the index so we can nest other stuff on it. We must do this once per higher record, | ||
nester_set(higher_record, record_to_nest, set_field, array_mode) | ||
apply_nester_modifications(nester_modification, record) | ||
apply_nester_modifications(nester_modification, record_to_nest) | ||
}) | ||
@@ -127,0 +128,0 @@ }) |
@@ -190,6 +190,10 @@ import { expect } from 'chai' | ||
], | ||
[['variants', 0, 'products', 0], [{ id: 1 }]], | ||
[['variants', 0, 'products', 0], [{ id: 1, title: 'my product' }]], | ||
[ | ||
['variants', 0, 'products', 0, 'images', 0], | ||
[{ variant_id: 1, url: 'test' }], | ||
], | ||
] | ||
const edges = [null, ['product_id', 'id']] | ||
const edges = [null, ['product_id', 'id'], ['id', 'variant_id']] | ||
@@ -203,3 +207,9 @@ const goal = { | ||
{ | ||
id: 1, | ||
title: 'my product', | ||
images: [ | ||
{ | ||
variant_id: 1, | ||
url: 'test', | ||
}, | ||
], | ||
}, | ||
@@ -213,3 +223,9 @@ ], | ||
{ | ||
id: 1, | ||
title: 'my product', | ||
images: [ | ||
{ | ||
variant_id: 1, | ||
url: 'test', | ||
}, | ||
], | ||
}, | ||
@@ -221,3 +237,8 @@ ], | ||
let result = nester(data, edges, []) | ||
// deleting the product id makes sure the field is not deleted before adding | ||
// the copy to the index | ||
let result = nester(data, edges, [ | ||
{ additions: [], deletions: [] }, | ||
{ additions: [], deletions: [{ field: 'id' }] }, | ||
]) | ||
@@ -224,0 +245,0 @@ expect(result).to.deep.equal(goal) |
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
1654720
40514