Pull request (OPEN) · PR #992 feat(indiekit): declare a collection’s indexes with addCollection · @rmdes
Fixes #979.
Indiekit.addCollection(name, indexes) takes an optional array of indexes, each a key plus any createIndex options such as unique. The core creates them in createIndexes(), called from server() after the plug-ins are installed and before serving; creating an existing index is a no-op, so it runs on every start.
The literal posts and media loop in index.js goes: the Micropub and media endpoints declare { key: { "properties.uid": 1 } } where they add their collections, and the Microsub endpoint declares its three (channel + id unique, channel + uid unique, channel + url) instead of creating them at init. The uid backfill stays where it was. Docs page updated.
Two core tests (declared indexes are created, a collection declares none by default); the Microsub index test moves with the declaration.