ok, so I guess that no-one is using dynamic models in their apps :(
I am looking through some code, and find this
var DataModel = loopback.PersistedModel || loopback.DataModel;
function loadModel(jsonFile) {
var modelDefinition = require(jsonFile);
return DataModel.extend(modelDefinition.name,
modelDefinition.properties,
{
relations: modelDefinition.relations
});
}
var UserIdentityModel = loadModel('./models/user-identity.json');
var UserCredentialModel = loadModel('./models/user-credential.json');
var ApplicationCredentialModel = loadModel(
'./models/application-credential.json');
exports.UserIdentity = require('./models/user-identity')(UserIdentityModel);
exports.UserCredential = require('./models/user-credential')(
UserCredentialModel);
exports.ApplicationCredential = require('./models/application-credential')(
ApplicationCredentialModel);
exports.UserIdentity.autoAttach = 'db';
exports.UserCredential.autoAttach = 'db';
exports.ApplicationCredential.autoAttach = 'db';
exports.PassportConfigurator = require('./passport-configurator');
in loopback-component-passport, which seems to dynamically add a couple of models to loopback
Trouble is, I can find no documentation that describes this technique - so
- is it valid ?
- can I use the same techniques ?
- does the autoattach actually work and add the model the the "db" database ?
I *really* would like to know the answers to the questions, it's so frustrating being on the tip of solving something to be confronted by the (lack of) documentation
If anyone could throw me a bone, I would appreciate it ;)
thanks