zod issue

Hello, this is really nice however we are getting this error when we need to return an array :

export const getAll = zodQuery({
  returns: z.array(z.object(situationFields)),
  handler: async (ctx) => {
    const situations = await ctx.db.query('situations').collect();
    return situations ;
  },
});

Uncaught ZodError: [
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "promise",
    "path": [],
    "message": "Expected object, received promise"
  }
]
    at get error [as error] (../../../../node_modules/zod/lib/index.mjs:587:30)
    at parse (../../../../node_modules/zod/lib/index.mjs:663:4)
    at handler (../../../../node_modules/convex-helpers/server/zod.js:247:16) 

So using array as return breaks, but if we wrap it in an object its fine any array in an object returned is breaking, so for now we have to keep doing this by using the regulare query:

export const getAll = query({
  returns: zodToConvex(z.array(dbSituationFields)),
  handler: async (ctx) => {
    return await ctx.db.query('situations').collect();
  },
});
Was this page helpful?