clientside-model-manager
Basic Usage
1. define your models
var { Object; // when we retrieve an object from the database, append its values to this object}Backtestprototype = { // validate the options var valid error = this; ifvalid !== true throw error; // pass request to server var database_object = await api; // let the server handle interpreting and validating the where string // cast server response to backtest objects var casted_object = database_object; // same as `new Backtest(database_object)`` // return the data return data; }
2. initialize the model manager
var active_models = "Plan" : "/_models/plan.js" "Funding" : "/_models/funding.js" "Backtest" : path:"/_models/backtest.js" preload:truevar models = active_modelsmoduleexports = models;
3. use the models - like you would with sequelize or mongodb
var models = await modelsBacktest
Caching
Since making requests to the database is expensive from the client, the module manager comes with the ability to cache data. The only thing a developer must keep in mind while using the caching functionality is that the developer will need to manually trigger data_pulls from the database to ensure that data is up to date.
- note, automatic timed updates will be availible in future - but this will still not resolve this problem entirely