Last active
October 7, 2017 02:16
-
-
Save govorov/db95a639c9eea353116b9fb430852831 to your computer and use it in GitHub Desktop.
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
| export const databaseInitializer = async () => { | |
| return await createConnection({ | |
| type : 'postgres', | |
| host : '0.0.0.0', | |
| port : 5432, | |
| username : 'db_user', | |
| password : 'db_password', | |
| database : 'db_name', | |
| entities: [ | |
| Card, | |
| ], | |
| synchronize: true, | |
| }).then((connection) => { | |
| console.log('Database connection established'); | |
| // Create new instance | |
| const card = new Card(); | |
| card.title = 'First card'; | |
| card.done = false; | |
| // Persist to database | |
| return connection.manager | |
| .save(card) | |
| .then(card => { | |
| console.log('card saved'); | |
| }) | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment