SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // initializers/database.ts
  3. //
  4. const path = require('path');
  5. import { createConnection } from 'typeorm';
  6. import { Card } from 'entities/card';
  7.  
  8.  
  9. export const databaseInitializer = async () => {
  10.  
  11.     return await createConnection({
  12.         driver: {
  13.             type     : 'postgres',
  14.             host     : '0.0.0.0',
  15.             port     : 5432,
  16.             username : 'finch',
  17.             password : 'finch',
  18.             database : 'finch_development'
  19.         },
  20.         entities: [
  21.             Card,
  22.         ],
  23.         autoSchemaSync: true,
  24.     }).then((...args) => {
  25.         debugger
  26.         console.log('Database connection established');
  27.     });
  28.  
  29. };
  30.  
  31.  
  32. //
  33. // entities/card.ts
  34. //
  35. import {
  36.     Entity,
  37.     PrimaryGeneratedColumn,
  38.     Column,
  39. } from 'typeorm';
  40.  
  41.  
  42. @Entity()
  43. export class Card {
  44.  
  45.     @PrimaryGeneratedColumn('uuid')
  46.     id: number;
  47.  
  48.     @Column('text')
  49.     title: string;
  50.  
  51.     @Column('boolean')
  52.     done: boolean;
  53.  
  54. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top