Check out v4 of the Fauna CLI
v4 of the Fauna CLI is now in beta. The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start. |
Collection.byName()
Get a collection definition by the collection’s name.
Description
Gets a collection definition, represented as a
Collection
document, by the collection’s name.
Collection
documents are FQL versions of a database’s FSL
collection schema. Collection
documents
have the CollectionDef type. See
Collections.
Staged schema
If a database has staged schema, this method interacts with the database’s staged schema, not the active schema.
Return value
Type | Description |
---|---|
Resolved reference to a
|
Examples
Collection.byName("Product")
{
name: "Product",
coll: Collection,
ts: Time("2099-07-30T22:55:21.520Z"),
history_days: 0,
constraints: [
{
unique: [
{
field: ".name",
mva: false
}
],
status: "active"
},
{
check: {
name: "stockIsValid",
body: "(product) => product.stock >= 0"
}
},
{
check: {
name: "priceIsValid",
body: "(product) => product.price > 0"
}
}
],
indexes: {
byCategory: {
terms: [
{
field: ".category",
mva: false
}
],
queryable: true,
status: "complete"
},
sortedByCategory: {
values: [
{
field: ".category",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
},
byName: {
terms: [
{
field: ".name",
mva: false
}
],
queryable: true,
status: "complete"
},
sortedByPriceLowToHigh: {
values: [
{
field: ".price",
order: "asc",
mva: false
},
{
field: ".name",
order: "asc",
mva: false
},
{
field: ".description",
order: "asc",
mva: false
},
{
field: ".stock",
order: "asc",
mva: false
}
],
queryable: true,
status: "complete"
}
},
fields: {
name: {
signature: "String"
},
description: {
signature: "String"
},
price: {
signature: "Int"
},
category: {
signature: "Ref<Category>"
},
stock: {
signature: "Int"
}
}
}
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!