DataRegistry
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.
Constructor
new DataRegistry()
Initialize a new DataRegistry.
Methods
authRuleForRepo()
authRuleForRepo(inputPath: string): AuthRule
Finds the authorization rule for the provided path.
decode()
decode(str: string): Schema
Decodes a schema marker to an actual schema.
encode()
encode(schema: Schema): string
Encodes a schema to a marker string for storage.
get()
get(ns: string, version: number): Schema
Find a schema that's been registered with this registry.
registerAuthRule()
registerAuthRule(path: string | RegExp<>, rule: AuthRule): void
Registers an authorization rule with this registry. If not provided, all data is considered public.
registerSchema()
registerSchema(schema: Schema): void
Registers a schema with this registry. This is a NOP if the schema had already been registered.
upgrade()
upgrade(data: CoreObject<>, dataSchema: Schema, targetSchema: Schema): [CoreObject<CoreValue>, Schema]
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.