Skip to content

null vs undefined generates a lot of boilerplate code #245

@pupeno

Description

@pupeno

Hello,

I'm new to Convex, so maybe I'm missing something, but so far I can't find it. I created a super tiny application, a CRUD for a table that just stores some numbers, that's it. This application ended up having a lot of boilerplate, with the structure of the data having to be defined 4 times, which feels very error prone.

One of the problems was that Convex demands nulls to represent blank fields in the API, and undefined to represent blank fields when calling db.patch, so there's a need to convert between these representations. This could be fixed by either db.patch accepting nulls or the API accepting (and not silently dropping) undefineds.

You can see the little app here: https://github.com/pupeno/convex-nextjs-playground

The reason there are 4 representations of the shape of the data is because there's an extra one for the schema, and another one for the form, because the forms, at least in React Hook Form, use "" to represent blank. I don't believe Convex can contribute in any way to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions