Create a collection

Problem

You need to create a new collection in the current database to store documents.

Solution

Use the CreateCollection function:

Copied!
client.query(
  q.({ name: 'huts' })
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  ref: ("huts"),
  ts: 1622573894320000,
  history_days: 30,
  name: 'huts'
}
Query metrics:
  •    bytesIn:   48

  •   bytesOut:  140

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    1

  •  readBytes:  802

  • writeBytes:  322

  •  queryTime: 48ms

  •    retries:    0

More information

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!