Get unique ID of the collection

Hi, How can I get the auto generated ID of the collection?

I created a Collection with this query:

  client.query(
        q.CreateCollection({ name: 'Books' })
    )
        .then((ret) => console.log(ret))
        .catch((err) => console.error('Error: %s', err))

It showed me this message:

{
  ref: Collection("Books"),
  ts: 1634797835650000,    
  history_days: 30,        
  name: 'Books'
}

I run this query to get the collection but I don’t see the autogenerated ID of the collection.

    client.query(
        q.Get(q.Collection('Books'))
    )
        .then((ret) => console.log(ret))
        .catch((err) => console.error('Error: %s', err))

Response:

{
  ref: Collection("Books"),
  ts: 1634797835650000,
  history_days: 30,
  name: 'Books'
}

How can I get the auto generated ID of the collection?

Hi @tola and welcome!

You already have it. :smiley:

The names for Databases, Collections, Indexes, Functions, Roles serve as the unique id’s for them.

Thank you. I was a little confused while reading about the data modeling.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.