What is Sequence

The module a-sequence provides a sequence feature, which can provide a unique sequence value for a specific business, such as assigning a unique name when creating a new atom draft

Definition of Sequence

Configure sequence in the meta of the module


sequence: {
  providers: {
    test: {
      start: 0,
      expression({ ctx, value }) {
        return ++value;
Name Description
test sequence name
test.start initial value
test.expression create a new value, supporting asynchronous function


Module a-sequence injects sequence into ctx.meta through middleware mechanism, which can facilitate the operations of sequence



let current = await this.ctx.meta.sequence.current('test');


let next = await this.ctx.meta.sequence.next('test');


await this.ctx.meta.sequence.reset('test');

Across Module

You can access the sequence values of other modules

// other module's sequence
const moduleSequence = this.ctx.meta.sequence.module(`test-party`);
// next
let next = await moduleSequence.next('test');