Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Objects retrieved from Fabric should be mapped to ConvectorModels in terms of their keys #106

Open
DanielKillenberger opened this issue Sep 24, 2019 · 1 comment
Labels
bug Something isn't working fabric Fabric related issues

Comments

@DanielKillenberger
Copy link

DanielKillenberger commented Sep 24, 2019

The problem

Functions on retrieved instances derived from a ConvectorModel like history and query promise to return an instance of a defined ConvectorModel. For example history(): Promise<History<T>[]>;
The Template T is as I understand it a model extending ConvectorModel.
Instead of returning an object of type T it returns an object where every key has the prefix '_' to the keys defined in T.

Current Behavior

history(): Promise<History<T>[]> does not return Promise<History<T>[]> but Promise<History<T2>[]> where T2 has '_' as the prefix to every key defined in T.

Expected Behavior

history(): Promise<History<T>[]> should actually return Promise<History<T>[]>

I think this is because those functions call the chaincode and just return the object returned from hyperledger fabric (I therefore suspect that all values are strings too). My expectation would be that the returned object would be cast to the specified ConvectorModel.

@diestrin
Copy link
Contributor

This is a problem in the way that Fabric is returning the response to client. A fix for this is in the way, expected to be merged and released in the next week.

In the meantime you can overcome this by doing (await myModel.history()) .map(item => ({...item, value: item.value.toJSON()}));, not a sexy fix, but can get you out of the problem right now.

@diestrin diestrin added bug Something isn't working fabric Fabric related issues labels Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fabric Fabric related issues
Projects
None yet
Development

No branches or pull requests

2 participants