fcms.resources.item

An item is any resource that’s been stored in a collection.

Items may also be organized in one or more taxonomies.

all-items

(all-items coll-slug)

Given the slug of the collection, return all the items it contains as a sequence of maps, or return :bad-collection if there’s no collection with that slug.

create-item

(create-item coll-slug item-name)(create-item coll-slug item-name props)

Create a new item in the collection specified by its slug, using the specified item name and an optional map of properties. If :slug is included in the properties it will be used as the item’s slug, otherwise the slug will be created from the name. :slug-conflict is returned if a :slug is included in the properties and an item already exists in the collection with that slug. :invalid-slug is returned if a :slug is included in the properties and it’s not valid. :property-conflict is returned if a property is included in the map of properties that is in the reserved-properties set.

delete-item

(delete-item coll-slug slug)

Given the slug of the collection containing the item and the slug of the item, delete the item and return true. :bad-collection is returned if there’s no collection with that slug. :bad-item is returned if there is no item with the specified slug.

get-item

(get-item coll-slug slug)

Given the slug of the collection containing the item and the slug of the item, return the item as a map, or return :bad-collection if there’s no collection with that slug, or nil if there is no item with that slug.

update-item

(update-item coll-slug slug props)

Update an item in 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 valid-item-update apply. If the item is updated successfully, the newly updated item is returned.

valid-item-update

(valid-item-update coll-slug slug props)

Given the slug of the collection, the slug of the item, and a map of updated properties for the item, check if the everything is in order to update the item. It ensures the collection exists or returns :bad-collection. It ensures the item exists or returns :bad-item. If a new slug is provided in the properties, it ensures it’s valid or returns :invalid-slug and ensures it’s unused or returns :slug-conflict. :property-conflict is returned if a property is included in the map of properties that is in the reserved-properties set.

valid-new-item

(valid-new-item coll-slug item-name)(valid-new-item coll-slug item-name props)

Given the slug of the collection, the name of the new item, and a map of the new item’s properties, check if the everything is in order to create the new item. Ensure the collection exists or return :bad-collection. Ensure the name of the item is specified or return :no-name. Ensure the slug is valid and doesn’t already exist if it’s specified, or return :invalid-slug or :slug-conflict respectively. :property-conflict is returned if a property is included in the map of properties that is in the reserved-properties set.