Add Synchronous Initial Load Option
Created by: xivSolutions
When configuring Massive in the context of an application, it may make sense to allow for a synchronous initial load option. We're after a cached instance of Massive from which we can query and otherwise access our precious data throughout the application life-cycle.
Folks might be tempted to initialize massive (using massive.connect()
) each and every time they want to pull some data, which adds the initialization overhead every time. Also, it will be more clear what is happening during initialization to clearly retrieve a db
instance at application load, as part of configuration.
It's not the "Node" way, but we should be able to do this when it makes sense:
var db = MassiveSync.loadSync({connectionString: constr});
// Set a reference to the massive instance on Express' app:
app.set('db', massiveInstance);