cdb/docs/Item.md
JMARyA 16353c7683
Some checks failed
ci/woodpecker/push/build Pipeline failed
quanta + properties
2025-05-18 22:30:18 +02:00

3.3 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.

Barcodes

You can associate barcodes with your item variants. This is useful for Quick Adding Items.

name: "Water"
variants:
  regular:
    name: "Regular Water"
    barcodes: [12345678]

Need Conditions

Some items prefer or need to be stored under some conditions. These conditions can be configured and warn you when locations dont match the required conditions.

name: "Water"
variants:
  regular:
    name: "Regular Water"
    needs:
      temperature: [5.0, 10.0]

Quantization

Sometimes items are homogenous and can be subdivided.
This can be defined via the unit of an Item Variant.
You define the base unit (the smallest possible instance) of an Item Variant. In this case ml.
Optionally you can define various conversions to bigger units by specifiying the units name and how many of the base unit this unit is.
In this case we define liter to be 1000 ml.

name: "Water"
variants:
  regular:
    name: "Regular Water"
    unit:
      by: "ml"
      conversions:
        liter: 1000

Properties

Some items might be more or less the same thing but come in various configurations.
To address such items you can define custom properties on Item Variants.
You can then use these properties to save and filter on metadata about your items.
This can be done by defining custom properties in a JSON schema like format in properties:

name: "iPhone"
variants:
  iphone:
    name: "iPhone"
    properties:
      color:
        enum: ["Black", "White", "Red"]
        description: "The Phone Color"
      ram:
        type: integer
        description: "The amount of RAM"