Collection.byName()
Get a collection document by its name.
Description
Each collection in a Fauna database is represented by a collection object, and each collection object has a name. This method gets the collection object by its name if it exists and is accessible.
Return value
One of:
Type | Description |
---|---|
Collection definition document. |
|
NullCollectionDef |
Collection object doesn’t exist or is inaccessible. |
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: "Number"
},
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!