Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. export const databaseInitializer = async () => {
  2.  
  3. return await createConnection({
  4. type : 'postgres',
  5. host : '0.0.0.0',
  6. port : 5432,
  7. username : 'finch',
  8. password : 'finch',
  9. database : 'finch_development',
  10. entities: [
  11. Card,
  12. ],
  13. synchronize: true,
  14. }).then((connection) => {
  15. console.log('Database connection established');
  16.  
  17. // Create new instance
  18. const card = new Card();
  19. card.title = 'First card';
  20. card.done = false;
  21.  
  22. // Persist to database
  23. return connection.manager
  24. .save(card)
  25. .then(card => {
  26. console.log('card saved');
  27. })
  28. });
  29.  
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement