2

I've got really good help with creating INSERT statements dynamically in a previous question: NodeJS and pg-promise, insert dynamically from JSON-object

I've tried to look at the docs, and would like to include RETURNING in the INSERT statement, so I get the inserted record as output with pg-promise.

I'm using NodeJS with pg-promise.

Is it possible to return the inserted record with all columns?

Community
  • 1
  • 1
Michael Nielsen
  • 1,194
  • 3
  • 22
  • 37

1 Answers1

3

You do so simply by appending the RETURNING clause to your query, and then executing it with a method according to the expected result.

For a complete example see the Extras section in Multi-row insert with pg-promise.

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