Skip to content

Commit

Permalink
fix(core): with method broken for relations (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
Idered authored Mar 9, 2018
1 parent e3741f5 commit a3f645e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/lib-js-core/src/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Data extends QueryBuilder {
const load = new Data(this.instance)
let ids = references.map(item => item.value)

ids = Array.isArray(ids[0]) ? ids[0] : ids
ids = Array.isArray(ids[0]) ? [].concat.apply([], ids) : ids

if (target === 'user') {
load._url = `${this._getInstanceURL(
Expand Down
16 changes: 14 additions & 2 deletions packages/lib-js-core/test/unit/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,15 @@ describe('Data', () => {
{
title: 'Awesome post',
comments: {
value: [1, 2],
value: [1],
type: 'relation',
target: 'comment'
}
},
{
title: 'Awesome post 2',
comments: {
value: [2],
type: 'relation',
target: 'comment'
}
Expand All @@ -531,7 +539,11 @@ describe('Data', () => {
.should.become([
{
title: 'Awesome post',
comments: [{id: 1, content: 'Hello'}, {id: 2, content: 'World'}]
comments: [{id: 1, content: 'Hello'}]
},
{
title: 'Awesome post 2',
comments: [{id: 2, content: 'World'}]
}
])
})
Expand Down

0 comments on commit a3f645e

Please sign in to comment.