Namespaces are an extension to the ability to pass true to server.models(true) in order to access all models (from the perspective of the root server), and similarly for server.knex(true). Now you may also pass a plugin name as a string server.models('my-plugin') (and server.knex('my-plugin')) in order to access models/knex from the perspective of that plugin. In other words, calling server.models() inside my-plugin is the same as calling server.models('my-plugin') from any plugin; identically calling server.models() on the root server is the same as calling server.models(true) from any plugin.
Sandboxing is a mechanism to opt-out of models being available to all ancestor plugins/namespaces of the plugin that registered the model, and same goes with knex instances for child plugins/namespaces. This essentially is the schwifty-y way of having models and knex instances that are "private" within the plugin that registered them.
These features work together to enable better plugin encapsulation and greater testability, with the ability to not only access, but also mock-out models on a per-plugin basis.
See also https://github.com/hapipal/schmervice/pull/10 where similar features are implemented for schmervice.
Namespaces are an extension to the ability to pass
true
toserver.models(true)
in order to access all models (from the perspective of the root server), and similarly forserver.knex(true)
. Now you may also pass a plugin name as a stringserver.models('my-plugin')
(andserver.knex('my-plugin')
) in order to access models/knex from the perspective of that plugin. In other words, callingserver.models()
insidemy-plugin
is the same as callingserver.models('my-plugin')
from any plugin; identically callingserver.models()
on the root server is the same as callingserver.models(true)
from any plugin.Sandboxing is a mechanism to opt-out of models being available to all ancestor plugins/namespaces of the plugin that registered the model, and same goes with knex instances for child plugins/namespaces. This essentially is the schwifty-y way of having models and knex instances that are "private" within the plugin that registered them.
These features work together to enable better plugin encapsulation and greater testability, with the ability to not only access, but also mock-out models on a per-plugin basis.