How to do " Starting with " query on User table

Hello community,
I have an object which username is “BjiRB2acKwKZvlFiaxhotGEAR” in the User table, and I want to query this object with the string “BjiRB” and only get it’s “ethAddress”. How can I do that query using cloud funtion? thanks.

I think that you can get the list of all users inside the cloud function and in the same cloud function iterate over all users to get only the ones that start with a particular string.

1 Like

an example from the documentation:

Moralis.Cloud.define("averageStars", async (request) => {
  const query = new Moralis.Query("Review");
  const results = await query.find();
  let sum = 0;
  for (let i = 0; i < results.length; ++i) {
    sum += results[i].get("stars");
  return sum / results.length;
  fields : ['movie'],
  requireUser: true