Skip to content

Class: DataModel<ModelTypes, ModelAliases>

datamodel.DataModel

The DataModel runtime provides APIs for interacting with datamodel aliases in applications and libraries. The ModelManager provides complementary APIs for managing datamodels during development.

It is exported by the datamodel module.

import { DataModel } from '@glazed/datamodel'

Type parameters

Name Type
ModelTypes extends ModelTypeAliases
ModelAliases extends ModelTypesToAliases<ModelTypes> = ModelTypesToAliases<ModelTypes>

Constructors

constructor

new DataModel<ModelTypes, ModelAliases>(params)

Type parameters

Name Type
ModelTypes extends ModelTypeAliases<Record<string, any>, Record<string, string>, Record<string, string>>
ModelAliases extends ModelTypesToAliases<ModelTypes> = ModelTypesToAliases<ModelTypes>

Parameters

Name Type
params DataModelParams<ModelAliases>

Accessors

aliases

get aliases(): ModelAliases

Model aliases provided in constructor.

Returns

ModelAliases


loader

get loader(): TileLoader

TileLoader instance used internally.

Returns

TileLoader

Methods

createTile

createTile<Alias, ContentType>(schemaAlias, content, options?): Promise<TileDocument<ContentType>>

Create a TileDocument using a schema identified by the given schemaAlias.

Type parameters

Name Type
Alias extends string | number | symbol
ContentType ModelTypes["schemas"][Alias]

Parameters

Name Type
schemaAlias Alias
content ContentType
options CreateOptions

Returns

Promise<TileDocument<ContentType>>


getDefinitionID

getDefinitionID<Alias>(alias): null | string

Returns the definition stream ID for a given alias, if present in local model aliases.

Type parameters

Name Type
Alias extends string | number | symbol

Parameters

Name Type
alias Alias

Returns

null | string


getSchemaURL

getSchemaURL<Alias>(alias): null | string

Returns the schema stream URL for a given alias, if present in local model aliases.

Type parameters

Name Type
Alias extends string | number | symbol

Parameters

Name Type
alias Alias

Returns

null | string


getTileID

getTileID<Alias>(alias): null | string

Returns the tile stream ID for a given alias, if present in local model aliases.

Type parameters

Name Type
Alias extends string | number | symbol

Parameters

Name Type
alias Alias

Returns

null | string


loadTile

loadTile<Alias, ContentType>(alias): Promise<null | TileDocument<ContentType>>

Load the TileDocument identified by the given alias.

Type parameters

Name Type
Alias extends string | number | symbol
ContentType ModelTypes["schemas"][ModelTypes["tiles"][Alias]]

Parameters

Name Type
alias Alias

Returns

Promise<null | TileDocument<ContentType>>