What have you done to persist the User data in production? Is there an easy way to find the schema of the User model so it can be reproduced in a database?
(Preemptive Note: DiscoverSchema finds the schema of the database, not the model)
(Also, I know the docs say the User model can be persisted by setting the file property in the default db datasource, but I have security, scalability, and durability concerns with that.)
"mongodb_dev": {
"name": "mongodb_dev",
"connector": "mongodb",
"host": "127.0.0.1",
"database": "devDB",
"username": "devUser",
"password": "devPassword",
"port": 27017
}
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"loopback/server/mixins",
"../common/mixins",
"./mixins"
]
},
"User": {
"dataSource": "mongodb_dev"
},
"AccessToken": {
"dataSource": "mongodb_dev",
"public": false
},
"ACL": {
"dataSource": "mongodb_dev",
"public": false
},
"RoleMapping": {
"dataSource": "mongodb_dev",
"public": false
},
"Role": {
"dataSource": "mongodb_dev",
"public": false
}
}
3.Create server/create-lb-tables.js file to move the built-in tables to your database with the following
var server = require('./server');
var ds = server.dataSources.mongodb_dev;// <<<<<<note the datasource name
var lbTables = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role'];
ds.automigrate(lbTables, function(er) {
if (er) throw er;
console.log('Loopback tables [' + lbTables + '] created in ', ds.adapter.name);
ds.disconnect();
});
cd server
node create-lb-tables.jsThis is a link to the official docs about putting built in models on your db
https://docs.strongloop.com/display/public/LB/Creating+database+tables+for+built-in+models
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With