Table of contents

Public class

Signature
class StoreSchema<R extends UnknownRecord, P = unknown> {}
References

UnknownRecord

Source

packages/store/src/lib/StoreSchema.ts


Properties

migrations

Public readonly property

Signature
readonly migrations: Record<string, MigrationSequence>
References

MigrationSequence


sortedMigrations

Public readonly property

Signature
readonly sortedMigrations: readonly Migration[]
References

Migration


types

Public readonly property

Signature
readonly types: {
  [Record in R as Record['typeName']]: RecordType<R, any>
}
References

RecordType


Methods

create()

Public static method

Signature
static create<R extends UnknownRecord, P = unknown>(
  types: {
    [TypeName in R['typeName']]: {
      createId: any
    }
  },
  options?: StoreSchemaOptions<R, P>
): StoreSchema<R, P>
Parameters
NameDescription

types

{
  [TypeName in R['typeName']]: {
    createId: any
  }
}

options

StoreSchemaOptions<R, P>
Returns
StoreSchema<R, P>
References

UnknownRecord, StoreSchemaOptions, StoreSchema


getMigrationsSince()

Public method

Signature
getMigrationsSince(
  persistedSchema: SerializedSchema
): Result<Migration[], string>
Parameters
NameDescription

persistedSchema

SerializedSchema
Returns
Result<Migration[], string>
References

SerializedSchema, Migration


migratePersistedRecord()

Public method

Signature
migratePersistedRecord(
  record: R,
  persistedSchema: SerializedSchema,
  direction?: 'down' | 'up'
): MigrationResult<R>
Parameters
NameDescription

record

R

persistedSchema

SerializedSchema

direction

'down' | 'up'
Returns
MigrationResult<R>
References

SerializedSchema, MigrationResult


migrateStoreSnapshot()

Public method

Signature
migrateStoreSnapshot(
  snapshot: StoreSnapshot<R>
): MigrationResult<SerializedStore<R>>
Parameters
NameDescription

snapshot

StoreSnapshot<R>
Returns
MigrationResult<SerializedStore<R>>
References

StoreSnapshot, MigrationResult, SerializedStore


serialize()

Public method

Signature
serialize(): SerializedSchemaV2
References

SerializedSchemaV2


serializeEarliestVersion()

Public method

Signature
serializeEarliestVersion(): SerializedSchema
References

SerializedSchema


validateRecord()

Public method

Signature
validateRecord(
  store: Store<R>,
  record: R,
  phase: 'createRecord' | 'initialize' | 'tests' | 'updateRecord',
  recordBefore: null | R
): R
Parameters
NameDescription

store

Store<R>

record

R

phase

  | 'createRecord'
  | 'initialize'
  | 'tests'
  | 'updateRecord'

recordBefore

null | R
Returns
R
References

Store


StoreListenerStoreSchemaOptions