Open ratacat opened 4 years ago
I'm happy to open a pull request, just thought I'd run this by you guys for input first! @shawncplus @seanohue
Sorry about the late response to this -- this makes sense to me so far, though I'm going to take a look at the SQLite data source as well. Definitely take a swing at it, esp. since your solution seems like it would be backwards compatible with other datasources.
So I've gone through and experimented with setting up a sqlite datasource by @coderintherye, and one thing that I was struggling with is a way to initialize the same datasource into different entityLoaders. For example, currently if you wanted to use the same sqlite datasource for players and accounts, you'd have to write two separate datasources(with their own constructors)...or put your initialize calls into the fetch/update functions which doesn't seem ideal.
The init() function needs to be separate from the constructor, because the constructor is called when the datasource is created, not when the entityLoader is created.
I added a few lines of code into EntityLoader.js to allow each EntityLoader to make a call to an init() function in the datasource which would obliviate this need.
you could add this method and call it in the constructor
Then all you need is an init() method in the DataSource that takes in the entityloader config and initializes the database / tables as needed.