Loading schemas with SchemaLoader

Schemas define the object types and structure of the database. See Object schemas for detailed information about schemas in ZooDb.

import { SchemaLoader } from '@phfaist/zoodb/schemaloader';
class SchemaLoader()

Load schema object data from a collection of YAML or JSON source files, and dereference any { ‘$ref’: … } internal and external references.

Doc……..

Configuration options:

  • schemas - an object with the following properties:

    • schemas.schema_root - a filesystem path or URL where to look for schemas.

    • schemas.schema_rel_path - a relative path to prefix any schema name that we might want to look up. It will be interpreted as a path relative to the schema_root.

    • schemas.schema_add_extension - a filename extension to add to the bare schema name when looking up the schema. E.g. ‘.json’ or ‘.yml’.

    Example:

    schemas: {
        schema_root: 'https://errorcorrectionzoo.org/',
        schema_rel_path: '/schemas/',
        schema_add_extension: '.json',
    }
    
  • schema_names - a list of names of schemas to load for the zoo database. If null or undefined and the schema_root is a filesystem path, then the corresponding directory contents is inspected and files matching the given schema_add_extension are loaded as schemas.

  • fs - the filesystem access handle. We need the method readFile() for any requested filesystem paths. We also need the readdir() method if schema_names is null or undefined.

See also makeStandardZooDbYamlDataLoader() for a simplified loading.

SchemaLoader.SchemaLoader