Skip to content

Commit bee7d1c

Browse files
committedOct 26, 2020
fix(store): don't rewrite id for list type
1 parent 344529c commit bee7d1c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
 

Diff for: ‎src/store.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,9 @@ function get(Model, id) {
733733

734734
if (cachedModel) definitions.set(cachedModel, null);
735735
return setTimestamp(
736-
config.create(stringId ? { ...result, id: stringId } : result),
736+
config.create(
737+
!config.list && stringId ? { ...result, id: stringId } : result,
738+
),
737739
);
738740
} catch (e) {
739741
return setTimestamp(

Diff for: ‎test/spec/store.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,13 @@ describe("store:", () => {
14351435
]);
14361436
});
14371437

1438+
it("returns a list of models with parameters", () => {
1439+
expect(store.get([Model], { page: 1 })).toEqual([
1440+
{ id: "1", value: "test" },
1441+
{ id: "2", value: "other" },
1442+
]);
1443+
});
1444+
14381445
it("adds item to list of models", done => {
14391446
expect(store.get([Model]).length).toBe(2);
14401447
store
@@ -1589,7 +1596,9 @@ describe("store:", () => {
15891596
const setupDep = options => {
15901597
return {
15911598
items: [Model, options],
1592-
[store.connect]: () => ({ items: Object.keys(storage).map(key => storage[key]) }),
1599+
[store.connect]: () => ({
1600+
items: Object.keys(storage).map(key => storage[key]),
1601+
}),
15931602
};
15941603
};
15951604

0 commit comments

Comments
 (0)