Skip to content

Class: DataModel<ModelTypes, ModelAliases>

datamodel.DataModel

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

loader

get loader(): TileLoader

Returns

TileLoader

Methods

createTile

createTile<Alias, ContentType>(schemaAlias, content, __namedParameters?): 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
__namedParameters CreateOptions

Returns

Promise<TileDocument<ContentType>>


getDefinitionID

getDefinitionID<Alias>(alias): null | string

Type parameters

Name Type
Alias extends string | number | symbol

Parameters

Name Type
alias Alias

Returns

null | string


getSchemaURL

getSchemaURL<Alias>(alias): null | string

Type parameters

Name Type
Alias extends string | number | symbol

Parameters

Name Type
alias Alias

Returns

null | string


getTileID

getTileID<Alias>(alias): null | string

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>>