[SOLVED] How can I clone a table in DB programmatically?

Hello,

I have a table with current participants, which content gets deleted after the game session is over.

But before deleting it I want to clone this data into another table called “History” for example.

Every time a game session is over its content will be copied into the History table so that I can aggregate this data.

Can you suggest how to implement it? I tried looping over each record in the participant table to no avail.

Thank you.

I did it using the bulk write query https://v1docs.moralis.io/moralis-dapp/database/bulk-queries;

It didn’t work initially because there were “createdAt” columns and the likes from the source table. After deleting those it worked.

Also, this query works only from the cloud.

Thanks.

1 Like

you can connect directly to mongo db too

I don’t know it. I never worked with databases before. Plus moralis serves my needs well. Thanks.