json-schema-to-es-mapping
Version:
Generate Elastic Search mappings from JSON Schema
24 lines (21 loc) • 476 B
JavaScript
const { buildConfig } = require("./build-config");
function build(schema, config = {}) {
const { onComplete, onThrow } = config;
try {
config = buildConfig(config, schema);
properties = config.buildProperties(schema, config);
results = config.resultObj;
onComplete && onComplete(results);
return {
properties,
results
};
} catch (err) {
onThrow && onThrow(err);
throw err;
}
}
module.exports = {
build,
buildConfig
};