Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router return is getting wrong json #1043

Open
xkalf opened this issue Feb 1, 2025 · 1 comment
Open

router return is getting wrong json #1043

xkalf opened this issue Feb 1, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@xkalf
Copy link

xkalf commented Feb 1, 2025

What version of Elysia is running?

1.2.10

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

i used bun-sql with drizzle orm and nextjs

here is the drizzle config

import { drizzle } from 'drizzle-orm/bun-sql'
import * as schema from './schema'

export const db = drizzle(process.env.DATABASE_URL!, {
  casing: 'snake_case',
  schema
})

and router

export const packagesRouter = new Elysia({ prefix: '/packages' })
  .get('/', async () => {
    const res = await db.select().from(packagesTable)

    return res
  })

if i return res[0] is working but returning res is
getting
[object Object][object Object][object Object] response

Image

What is the expected behavior?

return the array of objects

What do you see instead?

No response

Additional information

[object Object][object Object][object Object]

Have you try removing the node_modules and bun.lockb and try again yet?

i tired

@xkalf xkalf added the bug Something isn't working label Feb 1, 2025
@xkalf
Copy link
Author

xkalf commented Feb 1, 2025

also this code is working but i want i don't need to specify response type

export const packagesRouter = new Elysia({ prefix: '/packages' })
  .get('/', async () => {
    const res = await db.select().from(packagesTable)

    return res
  }, {
    response: t.Array(packageSelectSchema)
  })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant