this my code :
exports.createStudent = async (
ctx,
studentID,
name,
email,
identityNumber,
password,
mobile,
) => {
// validate submitter to belong to Org2MSP
const clientMSPID = ctx.clientIdentity.getMSPID();
if (clientMSPID !== "Org2MSP") {
throw new Error(
"AUTHENTICATION_ERROR client is not authorized to create new products"
);
}
// Get ID of submitting client identity
const organizationId = ctx.clientIdentity.getID();
const Record = {
organizationId,
name,
email,
identityNumber,
password,
mobile,
docType: "student",
};
const seconds = ctx.stub.getTxTimestamp().seconds.toString();
const nanos = ctx.stub.getTxTimestamp().nanos.toString().slice(0, 3);
Record.createdAt = +`${seconds}${nanos}`;
await ctx.stub.putState(studentID, Buffer.from(JSON.stringify(Record), "utf8"));
return JSON.stringify({ Key: studentID, Record });
};
and then I just call the function
async CreateStudent(ctx) {
const args = super.parseArgs(ctx);
const Key = super.generateKey(ctx, 10);
const validatedArgs = super.validateSchema(studentSchema, args);
const {
name,
email,
identityNumber,
password,
mobile,
} = validatedArgs;
const output = await createStudent(
ctx,
Key,
name,
email,
identityNumber,
password,
mobile,
);
return output;
}
I need to invoke the code from the terminal with multiple students instead of inserting one by one is it possible?
thanks in advance