Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
PostgresError about statement syntax in postman using deno-postgres

Creating a deno app http server from a crash course, with Oak and deno-postgres modules , i'm trying to add some data to postgre, everything works fine until send data to database. I get 500 interval server error in Postman :

Json response in Postman after post request:

{
    "success": false,
    "msg": "PostgresError: syntax error at or near 'table'"
}

my code :

import { Client } from "https://deno.land/x/postgres@v0.14.3/mod.ts";
import { dbCreds } from '../config.ts'
//deno run --allow-net --allow-read --allow-env server.ts
// Init client
const client = new Client(dbCreds)

const addProduct = async ({ request, response }: { request: any, response: any }) => {    
    const body = await request.body()
    const product = body.value 

    if (!request.hasBody) {
        response.status = 400
        response.body = {
            success: false,
            msg: 'No data'
        }
    } else {
        try {
            await client.connect()

            const result = await client.queryObject("INSERT INTO table (name,description,price) VALUES ($1,$2,$3);", 
            product.name,
            product.description,
            product.price)

            response.status = 201
            response.body = {
                success: true,
                data: product
            }
        } catch (err) {
            response.status = 500
            response.body = {
                success: false,
                msg: err.toString()
            }
        } finally {
            await client.end()
        }
    }
}

Is it the right syntax to insert data with deno-postgres?

I'm using postgres@v0.14.3 and oak (https://deno.land/x/oak/mod.ts)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda