Manually creating Id objects
is there a way to convert a string into a document ID (e.g. into a
GenericId<"table">
)?3 Replies
You can just construct a
GenericId
(or Id
if you're using a schema) with the new keyword, but it's an unusual thing to do because the only places Ids come from is from the database, where they're already objects. Useful if you're deserializing your own serialization though.
@Airplane ids also support toJSON and fromJSON, in case that's useful