i'm doing a project in NodeJS about finantial control that uses a model for accounts (Class Accounts) which have some "private" attributes (_id
, _name
, _parent
, _balance
and _isDeleted
) and some methods (getters and setters plus others).
All created accounts (objects) are converted into a JSON and stored into a file (custom database), except their methods (only the attributes are passed to the JSON).
When I load the database file, I get the JSON containing all accounts and their attributes, and need to show them into a view page, using EJS engine.
But after converting into JSON and loading them they do not have their methods to get their private attributes anymore, and I couldn't think any way to get those info, except by using directly the attribute reference (like _id
, _name
, ...).
How can I get those attributes according to OO design patterns, avoiding to make external references to private attributes of a class?
Thanks!