Skip to content

Commit

Permalink
Use external database from metasql module
Browse files Browse the repository at this point in the history
  • Loading branch information
tshemsedinov committed Nov 6, 2020
1 parent 612687d commit 23fbb3e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion application/api/example.1/citiesByCountry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async ({ countryId }) => {
const fields = ['Id', 'Name'];
const where = { countryId };
const data = await domain.database.example.select('City', fields, where);
const data = await domain.db.select('City', fields, where);
return { result: 'success', data };
};
2 changes: 1 addition & 1 deletion application/api/example.1/countries.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
async () => {
const fields = ['Id', 'Name'];
const data = await domain.database.example.select('Country', fields);
const data = await domain.db.select('Country', fields);
return { result: 'success', data };
};
3 changes: 2 additions & 1 deletion application/domain/database/start.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(async () => {
console.debug('Connect to pg');
domain.database.example = new lib.pg.Database(config.database);
const options = { ...config.database, logger: console };
domain.db = new npm.metasql.Database(options);
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
},
"dependencies": {
"impress": "^2.0.0-alpha.33",
"metasql": "^0.3.0-alpha.0",
"pg": "^8.4.2"
}
}

0 comments on commit 23fbb3e

Please sign in to comment.