Interface Database Decorators
Overview
The Interface Database Decorators package provides a structured, decorator-based framework for defining database tables, applying field-level modifiers (encryption, hashing, localization), building data models with CRUD operations, and injecting models into API controllers. It builds on top of the @antelopejs/interface-database package and integrates with the @antelopejs/interface-api package for controller parameter injection.
Dependencies
This package depends on the following:
- @antelopejs/interface-database - The underlying database query interface (AQL)
- @antelopejs/interface-api - API controller integration for parameter decoration
- @antelopejs/interface-core - Core decorator utilities
- reflect-metadata - Metadata reflection for TypeScript decorators
- randomstring - Random string generation for hash salts
Documentation
- Table Definitions - Define database tables with the
Tableclass,Indexdecorator, andFixturedecorator - Table Modifiers - Apply encryption, hashing, and localization modifiers to table fields, or create custom modifiers
- Data Models - Create data models with
BasicDataModelfor CRUD operations and data conversion - Parameter Decoration - Inject model instances into API controller methods with the
Modeldecorator
Change Events
The Changes<T> interface represents a change event emitted by change feeds. It includes the type of change and the document values before and after the change.
Table Definitions
The Database Decorators package provides a class-based approach to defining database tables. You extend the Table base class, declare each field with TypeScript's declare keyword and the @Field decorator, and use further decorators to configure indexes, relations, and initial data.