Skip to main content
Version: Next

Class: RecordSchema

A Schema defines the models allowed in a source, including their keys, attributes, and relationships. A single schema may be shared across multiple sources.

Hierarchy#

Constructors#

constructor#

new RecordSchema(settings?)

Parameters#

NameType
settingsRecordSchemaSettings

Inherited from#

Evented<RecordSchemaEvent>.constructor

Defined in#

packages/@orbit/records/src/record-schema.ts:118

Accessors#

models#

get models(): Dict<ModelDefinition>

Returns#

Dict<ModelDefinition>

Defined in#

packages/@orbit/records/src/record-schema.ts:226


version#

get version(): number

Version

Returns#

number

Defined in#

packages/@orbit/records/src/record-schema.ts:133

Methods#

_deprecateRelationshipModel#

_deprecateRelationshipModel(models): void

Parameters#

NameType
modelsDict<ModelDefinition>

Returns#

void

Defined in#

packages/@orbit/records/src/record-schema.ts:318


eachAttribute#

eachAttribute(type, callbackFn): void

Parameters#

NameType
typestring
callbackFn(name: string, attribute: AttributeDefinition) => void

Returns#

void

Defined in#

packages/@orbit/records/src/record-schema.ts:285


eachKey#

eachKey(type, callbackFn): void

Parameters#

NameType
typestring
callbackFn(name: string, key: KeyDefinition) => void

Returns#

void

Defined in#

packages/@orbit/records/src/record-schema.ts:296


eachRelationship#

eachRelationship(type, callbackFn): void

Parameters#

NameType
typestring
callbackFn(name: string, relationship: RelationshipDefinition) => void

Returns#

void

Defined in#

packages/@orbit/records/src/record-schema.ts:307


emit#

emit(event, ...args): void

Parameters#

NameType
eventEvent
...argsunknown[]

Returns#

void

Inherited from#

Evented.emit

Defined in#

packages/@orbit/core/dist/modules/evented.d.ts:23


generateId#

generateId(type?): string

Generate an id for a given model type.

Parameters#

NameType
type?string

Returns#

string

Defined in#

packages/@orbit/records/src/record-schema.ts:187


getAttribute#

getAttribute(type, attribute): AttributeDefinition

Parameters#

NameType
typestring
attributestring

Returns#

AttributeDefinition

Defined in#

packages/@orbit/records/src/record-schema.ts:239


getKey#

getKey(type, key): KeyDefinition

Parameters#

NameType
typestring
keystring

Returns#

KeyDefinition

Defined in#

packages/@orbit/records/src/record-schema.ts:249


getModel#

getModel(type): ModelDefinition

Parameters#

NameType
typestring

Returns#

ModelDefinition

Defined in#

packages/@orbit/records/src/record-schema.ts:230


getRelationship#

getRelationship(type, relationship): RelationshipDefinition

Parameters#

NameType
typestring
relationshipstring

Returns#

RelationshipDefinition

Defined in#

packages/@orbit/records/src/record-schema.ts:259


hasAttribute#

hasAttribute(type, attribute): boolean

Parameters#

NameType
typestring
attributestring

Returns#

boolean

Defined in#

packages/@orbit/records/src/record-schema.ts:273


hasKey#

hasKey(type, key): boolean

Parameters#

NameType
typestring
keystring

Returns#

boolean

Defined in#

packages/@orbit/records/src/record-schema.ts:277


hasModel#

hasModel(type): boolean

Parameters#

NameType
typestring

Returns#

boolean

Defined in#

packages/@orbit/records/src/record-schema.ts:269


hasRelationship#

hasRelationship(type, relationship): boolean

Parameters#

NameType
typestring
relationshipstring

Returns#

boolean

Defined in#

packages/@orbit/records/src/record-schema.ts:281


listeners#

listeners(event): Listener[]

Parameters#

NameType
eventEvent

Returns#

Listener[]

Inherited from#

Evented.listeners

Defined in#

packages/@orbit/core/dist/modules/evented.d.ts:24


off#

off(event, listener?): void

Parameters#

NameType
eventEvent
listener?Listener

Returns#

void

Inherited from#

Evented.off

Defined in#

packages/@orbit/core/dist/modules/evented.d.ts:21


on#

on(event, listener): () => void

Parameters#

NameType
eventEvent
listenerListener

Returns#

fn

▸ (): void

Returns#

void

Inherited from#

Evented.on

Defined in#

packages/@orbit/core/dist/modules/evented.d.ts:20


one#

one(event, listener): () => void

Parameters#

NameType
eventEvent
listenerListener

Returns#

fn

▸ (): void

Returns#

void

Inherited from#

Evented.one

Defined in#

packages/@orbit/core/dist/modules/evented.d.ts:22


pluralize#

pluralize(word): string

A naive pluralization method.

Deprecated in favor of inflectors now in @orbit/serializers

deprecated since v0.17, remove in v0.18

Parameters#

NameType
wordstring

Returns#

string

Defined in#

packages/@orbit/records/src/record-schema.ts:198


singularize#

singularize(word): string

A naive singularization method.

Deprecated in favor of inflectors now in @orbit/serializers

deprecated since v0.17, remove in v0.18

Parameters#

NameType
wordstring

Returns#

string

Defined in#

packages/@orbit/records/src/record-schema.ts:212


upgrade#

upgrade(settings?): Promise<void>

Upgrades Schema to a new version with new settings.

Emits the upgrade event to cue sources to upgrade their data.

Parameters#

NameType
settingsRecordSchemaSettings

Returns#

Promise<void>

Defined in#

packages/@orbit/records/src/record-schema.ts:142