I’m making a Discord bot and I’m using fauna for config/data files and I want to set the id of my documents to the id of the server. Is there a way that I can choose the id of a document when I create it? Also I’m using node.js
Hi @narutopig and Welcome,
yes, you can set your own id for the document. Of course, it has to be unique and the ref can only be numeric.
Below the way for creating a doc with a specific id:
Create(Ref(Collection("Discord"), "123456789"), {data: {id: 123456789}} )
{ ref: Ref(Collection("Discord"), "123456789"),
ts: 1606208265540000,
data: { id: 123456789 } }
and
Paginate(Documents(Collection("Discord")))
{ data: [ Ref(Collection("Discord"), "123456789") ] }
Hope this answer your question.
Luigi