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:
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))); Edite
make-index.tssegún sea necesario para su paquete de fragmentos. Use los comentarios como guía para completar la información requerida.Ejecute
ts-node make-index.tspara crear elindex.bson.br file.Sube
index.bson.bra tu repositorio de GitHub.Actualiza
snippetIndexSourceURLspara incluir una URL que haga referencia a tuindex.bson.br.