Skip to content

Instantly share code, notes, and snippets.

@govorov
Last active October 17, 2017 20:48
Show Gist options
  • Save govorov/2409dae530224524f0a85ecf1e5b98a0 to your computer and use it in GitHub Desktop.
Save govorov/2409dae530224524f0a85ecf1e5b98a0 to your computer and use it in GitHub Desktop.
graphql post
//
// initializers/database.ts
//
const path = require('path');
import { createConnection } from 'typeorm';
import { Card } from 'entities/card';
export const databaseInitializer = async () => {
return await createConnection({
driver: {
type : 'postgres',
host : '0.0.0.0',
port : 5432,
username : 'db_user',
password : 'db_password',
database : 'db_name'
},
entities: [
Card,
],
logging: ['query', 'error'],
synchronize: true,
}).then((...args) => {
debugger
console.log('Database connection established');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment