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
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
default | readonly | DataRegistry | The 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
| Parameter | Type | Description |
|---|---|---|
inputPath | string | The path to search for. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
str | string | The schema marker produced by a previous call to dataRegistry.encode. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
schema | Schema | The 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
| Parameter | Type | Description |
|---|---|---|
ns | string | The namespace for the schema. |
version? | number | If provided, searches for the specific version. Otherwise this method will return the latest version for the passed namespace. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
path | string | RegExp | Path to a repository or a RegExp instance. |
rule | AuthRule | A 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
| Parameter | Type | Description |
|---|---|---|
schema | Schema | The 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
| Parameter | Type | Description |
|---|---|---|
data | CoreObject | The data to upgrade. |
dataSchema | Schema | The schema of the passed data. |
targetSchema? | Schema | The 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.