0

When I use psql, there is confirmation after INSERT command. For example:

t34=# INSERT INTO t VALUES ('test');
INSERT 0 1

Is it possible to get this data (0, 1) with pg-promise package?

P.S. I speak about output INSERT oid count

Max Block
  • 1,134
  • 3
  • 16
  • 23
  • `pg-promise` gives you a promise. When the promise resolves - that's your confirmation. – vitaly-t Jul 18 '18 at 13:03
  • Yeah exactly, the 'then' functions execution tells you that the insertion is made successfully – gd vigneshwar Jul 18 '18 at 13:05
  • @vitaly-t Sorry, I think my original question was not clear. Is it possible to get INSERT oid count data? As I understand, db.none() returns Promise I've updated the question. – Max Block Jul 18 '18 at 13:12

1 Answers1

2
db.one('INSERT INTO t VALUES($1) RETURNING *', 'test')
    .then(data => {
        /* data = the inserted row object */
    })
    .catch(error => {
        /* failed */
    });

See method one.

Relevant reads: Multi-row insert with pg-promise.

vitaly-t
  • 24,279
  • 15
  • 116
  • 138