surrealdb / docs.surrealdb.com

The documentation for SurrealDB, powered by Astro
https://surrealdb.com/docs/
80 stars 143 forks source link

Documentation: What replaces Thing::from(("cats", Id::ulid())) ? #938

Open szabgab opened 1 month ago

szabgab commented 1 month ago

Description

I used to be able to generate an Id for a table using

use surrealdb::sql::{Id, Thing};

Thing::from(("cats", Id::ulid()))

How can I do it now with RecordId and RecordIdKey. The latter does not have a function called ulid

related: #893

Update:

It seems I can use this:

use surrealdb::sql::Id;
use surrealdb::{RecordId, RecordIdKey};

RecordId::from_table_key("cats", RecordIdKey::from(Id::ulid().to_string()));

but that just looks like way too much code.

Is there an existing issue for this?

Code of Conduct

Dhghomon commented 1 month ago

I've found something a little shorter, though agree it would be nice to have a RecordIdKey::ulid().

RecordId::from(("cats", RecordIdKey::from_inner(Id::ulid())));

@rushmorem Any thoughts on this?

szabgab commented 1 month ago

The thing is, that both my attempt and the one @Dhghomon suggested still use the surrealdb::sql::Id which, as I understand, is the old name.