CodingWithJamal
CodingWithJamal7mo ago

Convex ents

Hey, ive been playing with using convex ents today and like it. I didnt see an answer in the docs so im here... I like the idea of https://labs.convex.dev/convex-ents/schema#unique-fields , they can be helpful for things like an email field. however, when a uniue field is found, how does the convex function tell me this? I dont see any error type info on ents. I need a way to tell my froend end about this,
Ent Schema - Convex Ents
Relations, default values, unique fields and more for Convex
5 Replies
CodingWithJamal
CodingWithJamalOP7mo ago
@Michal Srb
Michal Srb
Michal Srb7mo ago
It's doing ctx.db.query(....).unique() under the hood, so it will throw (during insert).
CodingWithJamal
CodingWithJamalOP7mo ago
ah okay, so i can use a ConvexError on the client side to check if it didnt work?
Michal Srb
Michal Srb7mo ago
You can catch the thrown Error on the backend and rethrow a ConvexError, then you can use it on the client side.
CodingWithJamal
CodingWithJamalOP7mo ago
okay thanks

Did you find this page helpful?