A constructor isn't different from a class, it's part of the class.
A constructor is used when you invoke the class (similar to calling a function). The code inside of the constructor is ran, and a class instance is created and returned.
Here is an example, using the class from your post:
class PlayerStats {
Kills = 0;
Deaths = 0;
Joins = 0;
Cash = 0;
Wanted_Level = 0;
LastUsedIP = "0.0.0.0";
LUID = "0000000000000000000000000000000000000000";
PreviousData = false;
constructor( ) {
// Do stuff here when the class is called like a function.
}
}
You can then use something like this, which will return a class instance:
PlayerStats( );
For the SQLite part of your post:
Yes, grabbing each row of data is necessary, but only once per player. If you don't, then you will have to query the database everytime you retrieve or update data, which is not recommended. You can just create an array, and store each player's stats in the array's slots via the PlayerStats class like the one in my code above.
Also, yes, you could match a value from the array in onPlayerJoin to make sure that data was loaded. This is actually my preferred method I personally use.