Hi I am new in hyperledger fabric. Like every one I set up the fabric chain through documentation and got it working on my ubuntu with fabric samples.I need to create chain code in which 2 objects are needed and there relationship should be defined. In fabcar the application end is explained really well but I'm having issues incorporating 2 objects as only one object (car) is used in fabcar
Now I have created the both object in my chain code like with different functions
async createItem(ctx,id ,Name, status, description, owner) {
const item = {
Name,
status,
description,
owner,
};
await ctx.stub.putState(id, Buffer.from(JSON.stringify(item)));
}
Now the issue i'm having is when I have to query them as described in fabcar function
async queryAllCars(ctx) {
const startKey = '';
const endKey = '';
const allResults = [];
for await (const {key, value} of ctx.stub.getStateByRange(startKey, endKey)) {
const strValue = Buffer.from(value).toString('utf8');
let record;
try {
record = JSON.parse(strValue);
} catch (err) {
console.log(err);
record = strValue;
}
allResults.push({ Key: key, Record: record });
}
console.info(allResults);
return JSON.stringify(allResults);
}
Here you can see threes no car identifier where Its saying specifically to the chain code that all entries of cars are needed .. So I was wondering If we have 2 objects in chain code how can it be done so I can tell the chain code specifically to get me Items or customers. I'm sorry for asking such a basic questions but please help me.