Wednesday, 3 May 2017

Bind message supplies 1 parameters, but prepared statement "" requires 2

I have a database goods with two columns id jsonb primary_key and name. Using this query:

const query = 'INSERT INTO "goods" (id, name) VALUES ($1, $2)'

together with the following data:

const data = {id: 1, name: "milk"};

gives me the following error:

{ [error: bind message supplies 1 parameters, but prepared statement "" requires 2]
  name: 'error',
  length: 130,
  severity: 'ERROR',
  code: '08P01',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'postgres.c',
  line: '1556',
  routine: 'exec_bind_message' }

I have a postgres database set up, connected via pg.Pool() and executing javascript to insert my data.



via optional

No comments:

Post a Comment