Table of contents

Public class

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

UnknownRecord

Source

packages/store/src/lib/StoreSchema.ts


Properties

currentStoreVersion

Public readonly property

Signature
get currentStoreVersion(): number

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


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(): SerializedSchema
References

SerializedSchema


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