Table of contents
class StoreSchema<R extends UnknownRecord, P = unknown> {}

Properties

migrations

readonly migrations: Record<string, MigrationSequence>

sortedMigrations

readonly sortedMigrations: readonly Migration[]

types

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

Methods

create()

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>

getMigrationsSince()

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

persistedSchema

SerializedSchema
Returns
Result<Migration[], string>

migratePersistedRecord()

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

record

R

persistedSchema

SerializedSchema

direction

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

migrateStoreSnapshot()

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

snapshot

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

serialize()

serialize(): SerializedSchemaV2

serializeEarliestVersion()

serializeEarliestVersion(): SerializedSchema

validateRecord()

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

StoreQueriesStoreSideEffects