32 lines
1 KiB
JavaScript
32 lines
1 KiB
JavaScript
var pgDB = require('pg');
|
|
var pgDBNamed = require('node-postgres-named');
|
|
|
|
module.exports = {
|
|
load: load,
|
|
setup: setup
|
|
};
|
|
|
|
function load(tcrud) {
|
|
// Create backend with id and uri
|
|
tcrud.backend.database.loadPostgres('pg/pagila','postgres://postgres:postgresql@localhost/pagila',pgDB,pgDBNamed);
|
|
}
|
|
|
|
function setup(tcrud,tcrudModel) {
|
|
|
|
// Create tcrud models
|
|
var tc = tcrud.config;
|
|
var t = tc.createTEntityNode(tcrudModel,'pagila');
|
|
t.tmeta.tmodel.tbackend = 'pg/pagila';
|
|
|
|
// Define model and columns
|
|
var tLanguage = tc.createTEntity(t,'language','language_id');
|
|
var tLanguageId = tc.createTField(tLanguage,'language_id');
|
|
var tLanguageName = tc.createTField(tLanguage,'name');
|
|
var tLanguageLastUpdate = tc.createTField(tLanguage,'last_update');
|
|
|
|
var tCountry = tc.createTEntity(t,'country','country_id');
|
|
var tCountryId = tc.createTField(tCountry,'country_id');
|
|
var tCountryCountry = tc.createTField(tCountry,'country');
|
|
var tCountryLastUpdate = tc.createTField(tCountry,'last_update');
|
|
}
|