Hello, I created a new class on a Moralis server and inserted some test data rows. Now I want to fetch different columns of this class and all data rows of the selected columns and put them in a JS data table.
For testing puposes, I actually map some mock data from a json file to the table elements.
Now I am trying to replace the mock table data with the Moralis class data. For that I tried querying the DB, but obviously I am not using the correct code lines.
Does anyone have an advice?
…
import data from "../mock-data.json";
const TopTable = () => {
const { Moralis, account } = useMoralis();
const user = Moralis.User.current();
const [parts, setParts] = useState(data);
async function getData() {
const CreateTable = Moralis.Object.extend("CreateTable");
const query = new Moralis.Query(CreateTable);
query.equalTo("ethAddress", account);
const result = await query.first();
}
return (
<div className="tableContent">
<table>
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>PartOrderer</th>
<th>PartTitle</th>
</tr>
</thead>
<tbody>
{parts.map((part) => (
<tr>
<td>{part.id}</td>
<td>{part.date}</td>
<td>{part.partOrderer}</td>
<td>{part.partTitle}</td>
</tr>
))}
</tbody>
</table>