At Game development, how to handle object’s lifecycle/ticks?

Context:

I’m a frontend dev mostly, with little knowledge of backend since you can do a lot with just Typescript, and out of boredom and to challenge myself I’m trying to make an “RTS Multiplayer war game” (ignore how stupid I’m for taking that big of a jump).

I’m doing the frontend with React, and i started coding the server with Socket.io, now for the database I’m looking into Redis (i also tried checking MongoDB but i hated how messy their return types are, I’m confused enough without that).

Previously for testing porpoises i coded a “mock database” with pure Typescript storing everything in constants and such, just to be able to start coding the logic for all my units and test if i was able to do it. Now i need to start migrating everything to this “real” database.

Problem:

Since i was using just Typescript, and my data was in constants, i could afford to keep the Unit‘s attributes and methods all in the same place, so it looked something like this:

(To make this as simple as posible, lets say my Unit only moves)

const unit = {
   currentLocation: { x: 0, y: 0 },
   targetLocation: { x: 20, y: 20 },
   move: () => {
      // Move some steps towards the targetLocation
      this.currentLocation = { /* ... */ }
   },
   tick: () => {
      this.move();
      await wait(1000); // wait 1 sec before the next tick
      this.tick();
   },
}

Now that I’m placing this at a database i asume that:

  1. I cannot store methods and i should only store the data.
  2. Also EVEN if i could have the methods in the DB, if the server would turn OFF, all the tick‘s loops would stop, and when turning it ON i would have to loop through the whole DB to start the tick loops again, which doesn’t sound right.

So my question is:

In the Game development Industry, how do you handle this?

  • Databases store only the data ?
  • how do you apply a lifecycle to each object of the game, that starts back again every time the server is back ON ?
  • Is is 1 lifecycle/tick per object or is it a single one for the whole game and it loops through the DB calling each object ?
  • If the tick method is for each unit/object of the game, should i somehow attach the methods to the objects every time the server goes ON?

Well, thank you for taking the time on reading and if you have any answers that would be great, if not, please redirect me to some community that could help or something, i have no idea where to get started or who to ask, since i know 0 gamedevs. I have basically been asking for suggestions to ChatGPT (and googleing).