How to implement callbacks on AWS RDS PostgreSQL using node.js

shle2821

I'm trying to implement a call back on NodeJS EC2 server that's interacting with AWS RDS Postgresql. I'm not quite sure how it's done. There seems to be a EventEmitter method within AWS-SDK's RDS module. It's designed for all RDS instance types like MySQL, Aurora, etc. Not specifically for postgres. All I'm trying to do is to get some kind of callback after an INSERT or DELETE query.

Vao Tsun

It is not specific if your postgres is RDS or standalone on EC2. You will need

var pg = require('pg'); var dbe={"result":null};

function Q(sqlQuery,callback) {
    /* async, vulnerable, simple */
    var conString = "postgres://"+dbUser+":"+dbPass+"@"+dbHost+":"+dbPort+"/"+dbName+"?ssl=true";
    pg.connect(conString, function(err, client, done) {
      if(err) {
        return console.error('error fetching client from pool', err);
      }
      client.query(sqlQuery, function(err, result) {
        done();//call `done()` to release the client back to the pool
        if(err) {
          return console.error('error running query', err);
        }
        dbe.result = result;
        //console.log(JSON.parse(result.setEncoding('utf8');));
        callback();
      });
    });
}

And calling

var res = Q('select now()', function(a) {console.log(dbe.result)});

or similar - I don't have a playground to test atm

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

how to insert and update data into postgresql from node js using if condition

分類Dev

Enable encryption on existing database - AWS RDS Postgresql

分類Dev

Understanding node.js callbacks 2.0

分類Dev

How can I interact with a RDS MySQL instance with Node.js Lambda function?

分類Dev

AWS ioredis with node js

分類Dev

Node.js : multiple callbacks from one function

分類Dev

How to implement Idle time in angular using native JS code?

分類Dev

How can I add a tooltip to a node that does not implement Control using FXML?

分類Dev

How to change AWS-RDS instance type without downtime?

分類Dev

how to load data from AWS RDS to Google BigQuery in streaming mode?

分類Dev

ソース接続としてのAzureData Factory AWS PostgreSQL RDS

分類Dev

how to check how many lines of code in file using node js

分類Dev

AWS RDS BatchExecuteStatementRequest

分類Dev

How to remove the boilerplate code when using q in node.js

分類Dev

How to convert image into webp using gm in node.js

分類Dev

How to read a parameter with a period using Express in Node JS?

分類Dev

How to use $inc operator for variables in MongoDB using Node.JS

分類Dev

How to do a atomic find and save using mongoose in Node.js

分類Dev

How to implement gotoxy() using printf()

分類Dev

Using callbacks with optional parameters

分類Dev

How to asynchronously make HTTP Requests in AWS Lambda Node.js runtime

分類Dev

AWS RDS PostgreSQL 9.5.4拡張機能postgis_tiger_geocoder Soundexがありませんか?

分類Dev

How to enable MultiAZ for an RDS Instance using Boto3?

分類Dev

Using spring-cloud-aws, when connecting to an RDS instance, where do I specify the database?

分類Dev

Getting a GeoServer talking to an AWS RDS?

分類Dev

how to implement multiline with d3.js?

分類Dev

How to make two query to redis from node.js using promise from when.js

分類Dev

Trouble using nested callbacks in NodeJS

分類Dev

How to implement HandlerFunc without using DefaultServeMux

Related 関連記事

  1. 1

    how to insert and update data into postgresql from node js using if condition

  2. 2

    Enable encryption on existing database - AWS RDS Postgresql

  3. 3

    Understanding node.js callbacks 2.0

  4. 4

    How can I interact with a RDS MySQL instance with Node.js Lambda function?

  5. 5

    AWS ioredis with node js

  6. 6

    Node.js : multiple callbacks from one function

  7. 7

    How to implement Idle time in angular using native JS code?

  8. 8

    How can I add a tooltip to a node that does not implement Control using FXML?

  9. 9

    How to change AWS-RDS instance type without downtime?

  10. 10

    how to load data from AWS RDS to Google BigQuery in streaming mode?

  11. 11

    ソース接続としてのAzureData Factory AWS PostgreSQL RDS

  12. 12

    how to check how many lines of code in file using node js

  13. 13

    AWS RDS BatchExecuteStatementRequest

  14. 14

    How to remove the boilerplate code when using q in node.js

  15. 15

    How to convert image into webp using gm in node.js

  16. 16

    How to read a parameter with a period using Express in Node JS?

  17. 17

    How to use $inc operator for variables in MongoDB using Node.JS

  18. 18

    How to do a atomic find and save using mongoose in Node.js

  19. 19

    How to implement gotoxy() using printf()

  20. 20

    Using callbacks with optional parameters

  21. 21

    How to asynchronously make HTTP Requests in AWS Lambda Node.js runtime

  22. 22

    AWS RDS PostgreSQL 9.5.4拡張機能postgis_tiger_geocoder Soundexがありませんか?

  23. 23

    How to enable MultiAZ for an RDS Instance using Boto3?

  24. 24

    Using spring-cloud-aws, when connecting to an RDS instance, where do I specify the database?

  25. 25

    Getting a GeoServer talking to an AWS RDS?

  26. 26

    how to implement multiline with d3.js?

  27. 27

    How to make two query to redis from node.js using promise from when.js

  28. 28

    Trouble using nested callbacks in NodeJS

  29. 29

    How to implement HandlerFunc without using DefaultServeMux

ホットタグ

アーカイブ