StoreSchema

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

Properties

migrations

readonly
readonly migrations: Record<string, MigrationSequence>

sortedMigrations

readonly
readonly sortedMigrations: readonly Migration[]

types

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

Methods

create()

static
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

Returns


getMigrationsSince()

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

Parameters

NameDescription

persistedSchema

Returns

Result<Migration[], string>

migratePersistedRecord()

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

Parameters

NameDescription

record

R

persistedSchema

direction

'down' | 'up'

Returns


migrateStoreSnapshot()

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

Parameters

NameDescription

snapshot

Returns


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

Prev
StoreQueries
Next
StoreSideEffects