2017-12-23 21:45:27 +00:00
|
|
|
const { Pool } = require('pg');
|
2017-06-10 14:53:29 +00:00
|
|
|
var pgDBNamed = require('node-postgres-named');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
setup: setup,
|
|
|
|
load: load
|
|
|
|
};
|
|
|
|
|
|
|
|
function load(tcrud) {
|
|
|
|
|
2017-12-23 21:45:27 +00:00
|
|
|
const pool = new Pool({connectionString: 'postgres://postgres:postgresql@localhost/moviedb'});
|
|
|
|
|
2017-06-10 14:53:29 +00:00
|
|
|
// Create backend with id and uri
|
2017-12-23 21:45:27 +00:00
|
|
|
tcrud.backend.database.loadPostgres('pg/moviedb', pool, pgDBNamed);
|
2017-06-10 14:53:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setup(tcrud,tcrudModel) {
|
|
|
|
|
|
|
|
// Create tcrud models
|
|
|
|
var tc = tcrud.config;
|
|
|
|
var t = tc.createTEntityNode(tcrudModel,'moviedb');
|
|
|
|
t.tmeta.tmodel.tbackend = 'pg/moviedb';
|
|
|
|
|
|
|
|
// Define model and columns
|
|
|
|
var tCompany = tc.createTEntity(t,'company','company_id');
|
|
|
|
var tCompanyId = tc.createTField(tCompany,'company_id');
|
|
|
|
var tCompanyName = tc.createTField(tCompany,'name');
|
|
|
|
var tCompanyDateEst = tc.createTField(tCompany,'date_est');
|
|
|
|
var tCompanyRemarks = tc.createTField(tCompany,'remarks');
|
|
|
|
var tCompanyCountryId = tc.createTField(tCompany,'country_id');
|
|
|
|
|
|
|
|
var tCountry = tc.createTEntity(t,'country','country_id');
|
|
|
|
|
|
|
|
var tCountryCompany = tc.createTEntity(tCountry,'company','company_id');
|
|
|
|
var tCountryCompanyId = tc.createTField(tCountryCompany,'company_id');
|
|
|
|
var tCountryCompanyName = tc.createTField(tCountryCompany,'name');
|
|
|
|
var tCountryCompanyDateEst = tc.createTField(tCountryCompany,'date_est');
|
|
|
|
var tCountryCompanyRemarks = tc.createTField(tCountryCompany,'remarks');
|
|
|
|
var tCountryCompanyCountryId = tc.createTField(tCountryCompany,'country_id');
|
|
|
|
|
|
|
|
var tCountryId = tc.createTField(tCountry,'country_id');
|
|
|
|
var tCountryCode = tc.createTField(tCountry,'code');
|
|
|
|
var tCountryName = tc.createTField(tCountry,'name');
|
|
|
|
|
|
|
|
var tDirector = tc.createTEntity(t,'director','director_id');
|
|
|
|
var tDirectorId = tc.createTField(tDirector,'director_id');
|
|
|
|
var tDirectorDateBorn = tc.createTField(tDirector,'date_born');
|
|
|
|
var tDirectorDateDied = tc.createTField(tDirector,'date_died');
|
|
|
|
var tDirectorFirstName = tc.createTField(tDirector,'first_name');
|
|
|
|
var tDirectorLastName = tc.createTField(tDirector,'last_name');
|
|
|
|
|
|
|
|
var tGenre = tc.createTEntity(t,'genre','genre_id');
|
|
|
|
var tGenreId = tc.createTField(tGenre,'genre_id');
|
|
|
|
var tGenreCode = tc.createTField(tGenre,'code');
|
|
|
|
var tGenreName = tc.createTField(tGenre,'name');
|
|
|
|
|
|
|
|
tCompany.tmeta.tmenu.ticon='fa fa-building';
|
|
|
|
//tCountryCompany.tmeta.tmenu.ticon='fa fa-building';
|
|
|
|
tCountry.tmeta.tmenu.ticon='fa fa-globe';
|
|
|
|
tDirector.tmeta.tmenu.ticon='fa fa-cogs';
|
|
|
|
tGenre.tmeta.tmenu.ticon='fa fa-star';
|
|
|
|
}
|