fcms.resources.collection

A collection is a container for all the items that you’d like to be organized and searched together.

A collection may have none, one or many taxonomies and they are independent of each other.

all-collections

(all-collections)

Return all the collections in the system as a sequence of maps.

collection-count

(collection-count)

Return the number of collections in the system.

create-collection

(create-collection collection-name)(create-collection collection-name properties)

Create a new collection using the specified name and an optional map of properties.

If a :slug is included in the properties it will be used as the collection’s slug, otherwise a slug will be created from the name.

The same validity conditions and invalid return values as the valid-new-collection function apply.

If everything is OK, a map representing the newly created collection is returned.

delete-collection

(delete-collection slug)

Given the slug of the collection, delete it and all its contents and return true, or return :bad-collection if no collection exists for the specified slug.

If any portion of the bulk delete fails then the raw Couch DB bulk update response is returned.

get-collection

(get-collection slug)

Given the slug of the collection, return the collection as a map, or nil if there’s no collection with the specified slug.

item-count

(item-count slug)

Given the slug of the collection, return the number of items it contains, or return :bad-collection if there is no collection with the specified slug.

update-collection

(update-collection slug properties)

Update the collection specified by its slug using the specified map of properties.

If :slug is included in the properties the item will be moved to the new slug, otherwise the slug will remain the same.

The same validity conditions and invalid return values as the valid-collection-update function apply.

If everything is OK, a map representing the newly updated collection is returned.

valid-collection-update

(valid-collection-update slug properties)

Given the slug of the collection, and a map of updated properties for the collection, checks if the everything is in order to update the collection.

Ensures the collection exists or returns :bad-collection.

Ensures no reserved properties from common/reserved-properties are used or returns :property-conflict.

If a new slug is provided in the properties, ensures it is valid and unused or returns :invalid-slug or :slug-conflict respectively.

If everything is OK with the proposed update, true is returned.

valid-new-collection

(valid-new-collection collection-name)(valid-new-collection collection-name properties)

Given the name of a new collection, and a map of the new collection’s properties, check if the everything is in order to create the new collection.

Ensures the name of the item is specified or returns :no-name.

Ensures the slug is valid and doesn’t already exist if it’s specified, or returns :invalid-slug or :slug-conflict respectively.

If a property is included in the map of properties that is in the common/reserved-properties set of reserved property names :property-conflict is returned.

If everything is OK with the proposed new collection, true is returned.

with-collection

macro

(with-collection slug & body)

Given the slug of a collection, execute the code in the body with the retrieved collection lexically scoped as collection, or return :bad-collection if there is no collection with the specified slug.