INNER CODE UNIT · JavaScript

variant

mongodb/mongot · packages/search-index-schema/index.js:29

  const variant = candidates.find((v) => v.flags.every((flag) => enabled.has(flag)));

  if (!variant) {
    // Unreachable in practice: every index type declares a base variant with no required flags.
    throw new Error(`No schema variant matched for index type "${indexType}".`);
  }

  const schema = bundledSchemas[variant.schema];
  if (!schema) {
    throw new Error(`No bundled schema found for "${variant.schema}".`);
  }
  // Return an independent copy (JSON round-trip is portable across Node/browsers and lossless for
  // these pure-JSON schemas) so callers can't mutate the shared, cached module object.
  return JSON.parse(JSON.stringify(schema));
}

module.exports = { getSchema };

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…