Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
szabgab opened this issue Oct 15, 2024 · 2 comments
Open
2 tasks done

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

szabgab opened this issue Oct 15, 2024 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@szabgab
Copy link
Contributor

szabgab commented Oct 15, 2024

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?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@szabgab szabgab added the documentation Improvements or additions to documentation label Oct 15, 2024
@Dhghomon
Copy link
Contributor

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
Copy link
Contributor Author

szabgab commented Oct 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants