Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /

Crear un archivo de índice de registro manualmente

Advertencia

Funcionalidad experimental

Esta funcionalidad es experimental. MongoDB no proporciona soporte para Fragmentos. Esta funcionalidad puede ser cambiada o eliminada en cualquier momento sin previo aviso.

No se esperan errores, sin embargo, si encuentras alguno, abre un caso en el Repositorio de GitHub para este proyecto.

Esta página explica cómo crear manualmente un archivo de índice de registro. Para generar el archivo de índice de registro mediante un script, consulte Crear un archivo de índice del registro.

Para crear el archivo de índice de registro:

  1. Copie la siguiente plantilla de TypeScript y guárdela como make-index.ts:

    import bson from 'bson';
    import zlib from 'zlib';
    interface ErrorMatcher {
    // Add additional information to shell errors matching one of the regular.
    // expressions. The message can point to a snippet helping solve that error.
    matches: RegExp[];
    message: string;
    }
    interface SnippetDescription {
    // The *npm* package name. Users do not interact with this.
    name: string;
    // The snippet name. This is what users interact with.
    snippetName: string;
    // An optional install specifier that can be used to point npm towards
    // packages that are not uploaded to the registry. For example,
    // this could be an URL to a git repository or a tarball.
    installSpec?: string;
    // A version field. Users do not interact with this, as currently, `snippet`
    // always installs the latest versions of snippets.
    version: string;
    description: string;
    readme: string;
    // License should be a SPDX license identifier.
    license: string;
    errorMatchers?: ErrorMatcher[];
    }
    interface SnippetIndexFile {
    // This must be 1 currently.
    indexFileVersion: 1;
    index: SnippetDescription[];
    metadata: { homepage: string };
    }
    const indexFileContents: SnippetIndexFile = {
    indexFileVersion: 1,
    index: [ /* ... */ ],
    metadata: { homepage: 'https://example.com' }
    };
    // Serialize, compress and store the index file:
    fs.writeFileSync('index.bson.br',
    zlib.brotliCompressSync(
    bson.serialize(indexFileContents)));
  2. Edite make-index.ts según sea necesario para su paquete de fragmentos. Use los comentarios como guía para completar la información requerida.

  3. Ejecute ts-node make-index.ts para crear el index.bson.br file.

  4. Sube index.bson.br a tu repositorio de GitHub.

  5. Actualiza snippetIndexSourceURLs para incluir una URL que haga referencia a tu index.bson.br.

Volver

Manejadores de errores