cdb/docs/Item.md
2024-09-02 18:40:02 +02:00

1.7 KiB

Item

An item is the base concept for CDB. Everything is an Item. An Item describes a general product or object.

Defining an Item

An Item is defined within a markdown file with frontmatter. Items are the root dataset of CDB. One can use this as a starting point or create their own items.

For example, we define a "Water" Item:

---
name: "Water"
variants:
  common:
    name: "Common Water"
---

# Water
This is a Water Item

The file consist of the frontmatter, containing values for the item, and the rest of the markdown file containing a description.

Variants

Variants are different version of the same item. Each variant can have their own values. Each item needs at least one variant.

For our water example:

name: "Water"
variant:
  regular:
    name: "Regular Water"
  sparkling:
    name: "Sparkling Water"
  destilled:
    name: "Destilled Water"

Here we have defined three "Water" item variants.

Inventory

With the items defined, you can start tracking their inventory. See Transaction.

Min

You can set a minimum required inventory for an item variant. This will trigger events when an item reaches a low inventory threshold.

name: "Water"
variants:
  regular:
    name: "Regular Water"
    min: 2

This will ensure that at least two units of the "Regular Water" item variant are in inventory.

Expiry

You can set a default expiry time for an Item Variant. This value is defined as days until expiry.

name: "Water"
variants:
  regular:
    name: "Regular Water"
    expiry: 30

This will mark any item variant as expired if it's older than 30 days.