Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pool = new pg.Pool({
- user: 'devuser',
- database: 'ecommerce_api_dev',
- password: '',
- port: 5432,
- max: 10,
- idleTimeoutMillis: 30000
- });
- /*
- Create a store
- */
- createStore: function (req, res) {
- var dbname = 'store_' + generateID(1000000,9999999);
- var q_CreateStoreInfo = 'CREATE TABLE "public"."store_info" (' +
- '"id" serial,' +
- '"title" text,' +
- '"address" text,' +
- '"created_on" TIMESTAMP WITH TIME ZONE DEFAULT 'now()',' +
- '"inactive_on" TIMESTAMP WITH TIME ZONE DEFAULT null,' +
- '"active" boolean,' +
- '"subscription_type" text,' +
- 'PRIMARY KEY ("id")' +
- ');';
- pool.connect(function(err, client, done) {
- if (err) {
- return console.error('error fetching client from pool', err);
- }
- client.query('CREATE DATABASE ' + dbname, null, function(err, result) {
- if(err) {
- return console.error('[QUERY ERROR]', err);
- }
- console.log('[QUERY SUCCESS]', result);
- });
- client.query(q_CreateStoreInfo, null, function(err, result) {
- if(err) {
- return console.error('[QUERY ERROR]', err);
- }
- console.log('[QUERY SUCCESS]', result);
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement