Skip to content

Instantly share code, notes, and snippets.

@dougal83
Created November 2, 2018 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dougal83/5923474ee5c87c97b843b45b28d18c4b to your computer and use it in GitHub Desktop.
Save dougal83/5923474ee5c87c97b843b45b28d18c4b to your computer and use it in GitHub Desktop.
[LB4] Loopback 4 Automigrate Example (example/todo-list)
// Place in app root, build project (e.g: 'npm start'), execute (e.g. 'node automigrate.js')
const {DbDataSource} = require('./dist/src/datasources/db.datasource.js');
const {TodoRepository} = require('./dist/src/repositories/todo.repository.js');
const {TodoListRepository} = require('./dist/src/repositories/todo-list.repository.js');
const db = new DbDataSource();
const repoTodo = new TodoRepository(db);
const repoTodoList = new TodoListRepository(db);
db.automigrate(['Todo', 'TodoList']).then(
success => {
console.log('database was successfully updated');
process.exit(0);
},
error => {
console.error('cannot update the database', error);
process.exit(1);
}
);
@DanielJaramillo94
Copy link

Thanks for the example. I don't understand why do you use routes starting at "./dist"; the example does not have those folders. If I chanche the paths (deleting "/dist") there still error. The files in LB4 are not even JS files, so...

Even if I change .js for .ts, there are errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment