I am having hard time understanding how to use the Moralis.Query.fromJSON
method.
Below is an example code:
Moralis.Cloud.define("example", async (request) => {
const exampleData = [
{ name: "Ram", email: "[email protected]", age: 23 },
{ name: "Shyam", email: "[email protected]", age: 28 },
{ name: "John", email: "[email protected]", age: 33 },
];
const query = Moralis.Query.fromJSON("TestJsonObject", JSON.stringify(exampleData));
query.ascending("age");
const results = await query.find();
return results;
});
But when I call this, I get the following:
Error: Invalid parameter for query: 0
at handleError (RESTController.js?a0a1:435)
The reason why I need to use this is because I want to combine multiple classes, and the only way I found was to merge the objects (property) from each classes, convert to JSON, then put that JSON to Moralis.Query.fromJSON so I can do aggressions.