Checks if two metadata schemas have a mismatch.
This function compares two metadata schema arrays to determine if they contain the same fields with matching types. The comparison is order-independent and only considers the non-optional properties (name and type) of each field.
checkForSchemaMismatch(
customSchema: MetadataFieldSchema[],
inferredSchema: MetadataFieldSchema[]
): boolean| Name | Type | Description |
|---|---|---|
customSchema* | MetadataFieldSchema[] | |
inferredSchema* | MetadataFieldSchema[] |
The custom metadata schema to compare
The inferred metadata schema to compare against
const customSchema = [
{ name: "category", type: "tag" },
{ name: "price", type: "numeric" }
];
const inferredSchema = [
{ name: "price", type: "numeric" },
{ name: "category", type: "tag" }
];
checkForSchemaMismatch(customSchema, inferredSchema);
// Returns: false (schemas match, order doesn't matter)
const mismatchedSchema = [
{ name: "category", type: "text" }, // Different type
{ name: "price", type: "numeric" }
];
checkForSchemaMismatch(customSchema, mismatchedSchema);
// Returns: true (type mismatch for "category")