Skip to main content

Class: DataRegistry

Defined in: cfds/base/data-registry.ts:68

The DataRegistry acts as a registry of known schemas for a given GoatDB instance. It's initialized when the app starts and stays fixed during its execution.

Typically, apps use the DataRegistry.default instance, but are free to create multiple registries each with different schemas registered.

Constructors

Constructor

new DataRegistry(): DataRegistry

Defined in: cfds/base/data-registry.ts:81

Initialize a new DataRegistry.

Returns

DataRegistry

Properties

PropertyModifierTypeDescriptionDefined in
defaultreadonlyDataRegistryThe default instance. Unless explicitly specified, GoatDB will default to this instance.cfds/base/data-registry.ts:76

Methods

authRuleForRepo()

authRuleForRepo(inputPath): AuthRule

Defined in: cfds/base/data-registry.ts:243

Finds the authorization rule for the provided path.

Parameters

ParameterTypeDescription
inputPathstringThe path to search for.

Returns

AuthRule

An AuthRule or undefined.


decode()

decode(str): Schema

Defined in: cfds/base/data-registry.ts:221

Decodes a schema marker to an actual schema.

Parameters

ParameterTypeDescription
strstringThe schema marker produced by a previous call to dataRegistry.encode.

Returns

Schema

The registered schema or undefined if no such schema is found.


encode()

encode(schema): string

Defined in: cfds/base/data-registry.ts:207

Encodes a schema to a marker string for storage.

Parameters

ParameterTypeDescription
schemaSchemaThe schema to encode.

Returns

string

A string marker for this schema.


get()

get(ns, version?): Schema

Defined in: cfds/base/data-registry.ts:139

Find a schema that's been registered with this registry.

Parameters

ParameterTypeDescription
nsstringThe namespace for the schema.
version?numberIf provided, searches for the specific version. Otherwise this method will return the latest version for the passed namespace.

Returns

Schema

A schema or undefined if not found.


registerAuthRule()

registerAuthRule(path, rule): void

Defined in: cfds/base/data-registry.ts:116

Registers an authorization rule with this registry. If not provided, all data is considered public.

Parameters

ParameterTypeDescription
pathstring | RegExpPath to a repository or a RegExp instance.
ruleAuthRuleA function responsible for authorizing single items within repositories that match the given path.

Returns

void


registerSchema()

registerSchema(schema): void

Defined in: cfds/base/data-registry.ts:95

Registers a schema with this registry. This is a NOP if the schema had already been registered.

Parameters

ParameterTypeDescription
schemaSchemaThe schema to register.

Returns

void


upgrade()

upgrade(data, dataSchema, targetSchema?): [CoreObject<CoreValue>, Schema]

Defined in: cfds/base/data-registry.ts:166

Given a data object and its schema, this method performs the upgrade procedure to the target schema.

This method will refuse to upgrade to the target schema if a single version is missing. For example, if attempting to upgrade from v1 to v3, but the v2 schema is missing, then the upgrade will be refused.

NOTE: You shouldn't use this method directly under normal circumstances. The upgrade procedure will be performed automatically for you when needed.

Parameters

ParameterTypeDescription
dataCoreObjectThe data to upgrade.
dataSchemaSchemaThe schema of the passed data.
targetSchema?SchemaThe target schema. If not provided, the latest schema for the namespace will be used.

Returns

[CoreObject<CoreValue>, Schema]

An array in the form of [data, schema] with the result. Returns undefined if the upgrade failed.