edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
513 stars 65 forks source link

filter by uuid: Type '"std::uuid"' is not assignable to type '"std::str"' #276

Closed paulintrognon closed 2 years ago

paulintrognon commented 2 years ago

I am trying to filter a select query with a uuid which is of string type, and I don't know how to cast it into a std::uuid:

const image = await db.select(db.Image, (image) => ({
  filter: db.op(image.uuid, '=', 'b6b8993a-b836-4cad-84d1-ca9695c82f17'),
                ^^^^^^^^^^
                // Type '"std::uuid"' is not assignable to type '"std::str"'.
}))

I guess I have to transform the string into a Buffer, but it would be awesome if edgeql did that automatically. Or maybe have a built-in helper function to make the cast easy?

Thanks

Sikarii commented 2 years ago

Hey, there is indeed a helper available, give db.uuid a go!

paulintrognon commented 2 years ago

Oh, you're right. I did search for it in the documentation but could not find anything. Thank you for your help!