SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top