-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datastorage is semi-hardcoded for accounts #96
Comments
There's no need for 4 methods. CRU can all be accomplished with the current EntityLoader architecture. It might need a -- To all the rest that's the plan, it was mentioned in another ticket but the |
Any ETA on 3.2 where this will be fixed? I just ran into this when attempting to make case insensitive JSON based data/directory source (e.g. case insensitive account & player names/lookup). |
You can fix this by appending the /**
* @param {function} callback after-save callback
*/
save(callback) {
this.__manager.loader.update(this.username, this.serialize())
.then(() => callback());
} |
@azigler Can you give a little more detail on what you're describing above? I looked at the commit referenced here but that doesn't seem to be enough to make it work. EDIT: Wait, I think you just mean monkey patch in
? |
While the documentation suggests it is enough to switch out the EntityLoader to implement your custom data source, this is currently not entirely true for accounts. You can load them from any alternate source, but the only proper method for creating/saving them is calling save() on the Account object (as done by the example bundles). Save() on Account.js in turn calles the save() function on Data.js, which currently looks like this:
... regardless of the user implementation for the data source.
Work Around
To implement custom sources for accounts there are currently two ways--switching out Account.js with one imlementing a custom save() function (and consequently AccountManager which depends on it)--or to access the loader stored in AccountManager directly in your code via Accountmanager.loader.custom_loader_save_function(). The first is somewhat overkill if you have no intention of changing the fields/pw encryption Account provides while the later leaves it to the developer to make sure the loader they access from the Accountmanager is the one they hooked up and feels unintuitive.
Proposed Solution:
Optional Consideration:
EntityLoader currently has implementations for update/replace which are not used by AccountManager and inaccessible unless using the loader directly. There is also no delete function for cases when you do want to delete an account properly rather than just setting account.delete to true. It may be an interesting feature to add the full set of CRUD functions to the AccountManager so it can serve as a gateway to accessing all loader functions for usecases where people really only want to change how data is saved/loaded, but don't need custom implementations for accounts.
The text was updated successfully, but these errors were encountered: