I am new to loopback and i am just started to implement the tutorial https://docs.strongloop.com/display/public/LB/Connect+your+API+to+a+data+source
But i am receiving the error:
[error: relation "public.acl" does not exist].
I searched a lot for this, but cant find the solution. Please help me to solve this. Thanks..
As explained in the doc https://docs.strongloop.com/display/public/LB/Creating+database+tables+for+built-in+models Loopback doesn't automatically migrate (create) tables from models -- that includes built-in models.
So as the link suggests, in order to use other datasource than in-memory db, we should create a separate script server/create-lb-tables.js
:
var server = require('./server');
var ds = server.dataSources.postgresDS;
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();
});
where postgresDS
is the name of your datasource in server/datasources.json
.
Finally, run the script to migrate the tables:
$ cd server
$ node create-lb-tables.js
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