Hi everyone!
I have 2 files one is database.mo and other is main.mo. I tried to follow linkedup logic.
database.mo:
public func listCompanies(userid: Principal): async ?Company {
if(isStudent(userid)){
func isEq(company: Company): Bool {
company.owner == userid;
};
switch (Array.find<Company>(personalList, isEq)) {
case(null) {
return null;
};
case(?exists) {
return ?{
id = exists.id;
owner = exists.owner;
companyID = exists.companyID;
};
};
};
} else {return null;}
};
main.mo:
public shared(msg) func List(): async ?Company{
directory.listCompanies(msg.caller);
};
I tried to do something like this in main.mo file because I had some errors:
public shared(msg) func List(): async ?Company{
switch (directory.listCompanies(msg.caller))
{
case(?e){
return ?{
};
};
};
};
The error appears with the second try that I wrote above, and is this:
type error, option pattern cannot consume expected type
async<$List> (?Company)
What I have to do to solve this error? where is my mistake?
Thank you!