Created
September 3, 2020 01:46
-
-
Save viniciusstroher/f56c72bcd4f8d92310cadf6ed19b8a00 to your computer and use it in GitHub Desktop.
[LB4] Loopback 4 Automigrate Example (example/todo-list)
This file contains hidden or 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