diff --git a/src/store.js b/src/store.js index 7f797926..20bdd3a2 100644 --- a/src/store.js +++ b/src/store.js @@ -803,10 +803,19 @@ function setupListModel(Model, nested) { contexts, enumerable: modelConfig.enumerable, external: modelConfig.external, - placeholder: () => { + placeholder: (id) => { const model = Object.create(listPlaceholderPrototype); definitions.set(model, config); + Object.defineProperties(model, { + id: { value: id }, + toString: { + value: function () { + return this.id; + }, + }, + }); + return Object.freeze(model); }, isInstance: (model) => diff --git a/test/spec/store.js b/test/spec/store.js index 8108cabe..418cbce8 100644 --- a/test/spec/store.js +++ b/test/spec/store.js @@ -2086,8 +2086,13 @@ describe("store:", () => { }, }; + const pendingModel = store.get([Model], "test"); + + expect(pendingModel.id).toBe("test"); + expect(String(pendingModel)).toBe("test"); + return store - .pending(store.get([Model])) + .pending(pendingModel) .then((models) => store.pending(models[0]).then(() => models)) .then((models) => { const model = models[0]; @@ -2150,6 +2155,10 @@ describe("store:", () => { }; const pendingModel = store.get(Model, 1); + + expect(pendingModel.id).toBe("1"); + expect(String(pendingModel)).toBe("1"); + expect(store.pending(pendingModel)).toBeInstanceOf(Promise); expect(() => pendingModel.value).toThrow();