@decaf-ts/core
Version:
Core persistence module for the decaf framework
33 lines (32 loc) • 1.18 kB
TypeScript
import type { ModelArg } from "@decaf-ts/decorator-validation";
import { BaseModel } from "../../model";
/**
* @description RAM sequence model for auto-incrementing values
* @summary A model class that represents a sequence in the RAM adapter. It stores the current value
* of a sequence that can be used for generating sequential identifiers for entities.
* The sequence is identified by its ID and maintains the current value.
* @param {ModelArg<Sequence>} seq - Initial sequence data
* @class Sequence
* @category Ram
* @example
* ```typescript
* // Create a new sequence
* const orderSequence = new Sequence({ id: 'order_seq', current: 1 });
*
* // Use the sequence to get the next value
* const nextOrderId = parseInt(orderSequence.current.toString()) + 1;
* orderSequence.current = nextOrderId;
* ```
*/
export declare class RamSequenceModel extends BaseModel {
/**
* @description Primary key identifier for the sequence
*/
id: string;
/**
* @description Current value of the sequence
* Used to generate the next sequential value
*/
current: string | number;
constructor(seq?: ModelArg<RamSequenceModel>);
}