Hello,
I've integrated TypeORM and TypeScript into my gamemode to avoid writing SQL queries. However, loading and saving entities from and into the database is very slow and I do not know why. It seems that async calls are blocking for some reason.
async function bootstrap() {
const connection = await createConnection({
host: "localhost",
port: 5432,
database: "rage",
username: "rage",
password: "rage",
type: "postgres",
entities: [User, Vehicle],
synchronize: true,
logging: true,
});
mp.events.addCommand("veh", async (player: PlayerMp, fullText: string) => {
const vehicle: VehicleMp = mp.vehicles.new(mp.joaat(fullText), player.position);
const dbVehicle = new Vehicle();
dbVehicle.model = vehicle.model;
dbVehicle.position = vehicle.position;
await connection.manager.save(dbVehicle);
player.putIntoVehicle(vehicle, -1);
});
}
bootstrap();
Does anybody know why storing entities into the database take so much time? Any help is appreciated