Disclaimer first: I’m aware that JS can’t handle 64 bit integers out of the box.
Fauna document ids are string-encoded 64-bit integers (see here). Can one be generated through fauna JavaScript driver (or something similar) in advance of, for example, creating a document?
What I mean in pseudo code:
// some magic to create the document id
const id = magick()
// then I could
faunaClient.query(
Create(Ref(Collection('Foo'), id), {
data: {
bar: 'biz'
}
})
)
Sure, I get that I can supply my own id with the above. My question is: can I generate just the id. Without creating a document in Fauna. For example to store it in a variable for later use.
Just to be clear: I’m not asking if I can supply my own id - I know I can do that. I’m asking if Fauna JS driver can generate one for me without the need to create an actual document in the database.
For example:
const id = faunaClient.generateId()
console.log(id) // 327041507083158092