I have a stream of results coming from the github client as below.
stream<github:Repository, github:Error?> repositories = check githubEp->getRepositories("google", true);
And I have a defined record type named Repository as below.
type Repository record {|
string repoName;
int? stargazerCount;
|};
How do I create an array of Repository records by querying the stream?
You can follow two approaches here. You can use either query expressions or query actions. You can use it depending on the use case.
Repository[] repoArray = check from github:Repository repo in repositories
select {repoName: repo.name, stargazerCount: repo.stargazerCount};
Repository[] repoArray = [];
check from github:Repository repo in repositories
do {
repoArray.push({
repoName: repo.name,
stargazerCount: repo.stargazerCount
});
};