[Convex Ents] patch not working + patch has not correct typescript definitions
I wrote this code:
messages.ts
schema.ts
And as you can see in the image the mutation is called correctly. But message does not get patched.


12 Replies
if you need to you can go into my db. it's this project

i don't see why this is happening, but could it be because
content
should be v.optional(v.string())
if you're trying to set it to undefined
? (if that's the problem, i would expect patch to throw a schema error)Yeah, weird. Should I create another support thread covering that it's not throwing an error?
nah we can discuss that here. i'll look into it
does it throw the error if you
await
the patch?I will check that. But usually typescript should tell me if I can't pass an undefined
With this code it throws the error

But would be nice if TS warned me ๐. I will check if it works with content: ""
This code worked!!!
I think I was missing the second (outer) await
Should I create an issue for that (the typing) on the package's github or is it fine here?
What's the typing bug exactly? You can explain here.
That
content
was allowed to be undefined
in patch?Exactly
This is not a bug in Ents, but a limitation of the Convex TS types.
patch
accepts a subset of fields of the document.
But TypeScript does not distinguish between not providing a field and providing a field with the value undefined
.
You can see that the same issue exists in Convex without Ents.Oh, ok
Thank you
the reason why the error wasn't thrown at runtime either: https://github.com/xixixao/convex-ents/issues/26
GitHub
unawaited
patch
never executes ยท Issue #26 ยท xixixao/convex-entspromises in convex mutations usually run to completion, even if not awaited. for example, handler: async (ctx, { id }) => { ctx.db.patch(id, { foo: bar }); } will execute the patch. But this isn...