Created
November 2, 2018 09:42
-
-
Save dougal83/5923474ee5c87c97b843b45b28d18c4b to your computer and use it in GitHub Desktop.
[LB4] Loopback 4 Automigrate Example (example/todo-list)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.