Skip to content

Commit 0587b12

Browse files
updated getReference path method to remove duplicate values
1 parent e983d23 commit 0587b12

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Contentstack Ecosystem <[email protected]>",
33
"name": "datasync-mongodb-sdk",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"description": "Mongodb query wrapper around contents synced via @contentstack/content-store-mongodb",
66
"main": "dist/index.js",
77
"scripts": {

src/stack.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
merge,
99
mergeWith,
1010
remove,
11+
isArray
1112
} from 'lodash'
1213
import {
1314
Db,
@@ -2126,11 +2127,12 @@ export class Stack {
21262127

21272128
schemas.forEach((schema) => {
21282129
// Entry references
2129-
entryReferences = mergeWith(entryReferences, schema[this.types.references])
2130-
// tslint:disable-next-line: forin
2131-
for (const path in schema[this.types.assets]) {
2132-
paths.push(path)
2133-
}
2130+
entryReferences = mergeWith(entryReferences, schema[this.types.references], (existingReferences, newReferences) => {
2131+
if (isArray(existingReferences)) {
2132+
return Array.from(new Set(existingReferences.concat(newReferences)));
2133+
}
2134+
return existingReferences;
2135+
});
21342136
})
21352137

21362138
for (let i = 0, j = currentInclude.length; i < j; i++) {

test/data/assets.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const assets = [
88
title: 'A 1',
99
uid: 'a1',
1010
url:
11-
'https://images.contentstack.io/v3/assets/blt44d99c34b040fa61/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
11+
'https://images.contentstack.io/v3/assets/***REMOVED***/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
1212
},
1313
{
1414
_version: 1,
@@ -19,7 +19,7 @@ export const assets = [
1919
title: 'A 2',
2020
uid: 'a2',
2121
url:
22-
'https://images.contentstack.io/v3/assets/blt44d99c34b040fa61/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
22+
'https://images.contentstack.io/v3/assets/***REMOVED***/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
2323
},
2424
{
2525
_version: 2,
@@ -30,6 +30,6 @@ export const assets = [
3030
title: 'A 3',
3131
uid: 'a3',
3232
url:
33-
'https://images.contentstack.io/v3/assets/blt44d99c34b040fa61/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
33+
'https://images.contentstack.io/v3/assets/***REMOVED***/blt6788d40f2aaaab9a/5c5aae49005d89b20bb85c21/cnn.png',
3434
},
3535
]

0 commit comments

Comments
 (0)