Creating Collections
There are two main ways to create collections in Orionjs:Using the Repository Pattern (Recommended)
The recommended approach is to use the repository pattern with proper typing:Using createCollection Directly
You can also create collections directly:Configuration Options
ThecreateCollection
function accepts the following options:
ID Generation
Orionjs offers several options for generating document IDs:Basic ID Generation Options
'mongo'
(default): MongoDB ObjectId strings (time-based)'random'
: Random string IDs'uuid'
: UUID v7 strings
Typed IDs
For TypeScript users, Orionjs provides powerful ways to create type-safe IDs usingtypedId
:
typedId
from the schema and use it to create prefixed IDs.