Skip to content

Commit 2c0bbda

Browse files
updated getReference path method to remove duplicate values
1 parent 2ace7d2 commit 2c0bbda

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
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++) {

0 commit comments

Comments
 (0)