Just one more silly doubt :
public func putPost(newPost : Types.Post) : async (){
var curPPID : Nat = newPost.ppid;
if(curPPID == 0){
//make new xchange with hospost as newPost
var newXid : Nat = mapXchange.size() + 1;
var newXchange : bufferPost = Buffer.Buffer<Types.Post>(0);
newXchange.add(newPost);
mapXchange.put(newXid, newXchange);
};
if(curPPID != 0){
for(curXchange in mapXchange.vals()){
var curXchangeArray : [Types.Post] = curXchange.toArray();
if(curXchangeArray[0].xid == newPost.xid){
curXchange.add(newPost);
};
};
};
return ();
};
Above is a function to put a entity in a hashmap.
**Entity : hostPost **
let hostPost : Types.Post = {
pid = 1; // Post Id
uid = 1; // User Id
ppid = 0; // Parent Post Id, Null = no parent, so this is a hostPost
xid = 1; // Xchange Id
tid = 0; // Thread Id
cid = 0; // Conversation (= Discourse = Issue = Subject = Topic) Id)
iid = 0; // Instance Id
did = 0; // Debate Id
postType = "Introduction";
speakerName = "Carl";
createdAt = "2021-05-22 07:56:09.282+00";
summary = "Etiam imperdiet ullamcorper lorem. Integer ac nisi eget arcu.";
details = "<div><p>Pellentesque accumsan risus ut fermentum hendrerit!</p>\n<p>Nulla ac velit lobortis, iaculis mauris et, suscipit orci. Quisque viverra sem in aliquet bibendum. Etiam sodales tincidunt turpis convallis hendrerit. Maecenas luctus fringilla ex, vel rhoncus leo lobortis et. Cras laoreet sit amet justo vel viverra!</p></div>";
thumbnail = "";
titleFrame = "";
votable = true;
voteType = "resonate";
video = "hd9dwdbd8xv";
published = true;
};
But when i am trying to call this function in terminal to put above entity in hashmap , it is showing some syntax error.
Can you please correct this?
dfx canister call canisterName putPost '(hostPost)'
Error :Invalid argument: Invalid Candid values: Candid parser error: Unrecognized token Id("hostPost")
found at 0:8
Expected one of “(”, “blob”, “bool”, “decimal”, “float”, “func”, “hex”, “null”, “opt”, “principal”, “record”, “service”, “sign”, “text”, “variant” or "vec"