import { ModelApiLoader } from '@/api/model';
import joi, { joiString } from '@/validator/joi';

const schemaProductCategory = joi.object({
  from: joiString.required(),
  to: joiString.required(),
  categoryIdFrom: joiString.required(),
  categoryIdTo: joiString.required(),
});

export const MappingProductCategory = new ModelApiLoader('mapping_product_category', schemaProductCategory);

export const loaderIndex = () => {
  return Promise.allSettled([
    MappingProductCategory.createIndex({
      index: {
        fields: ['from', 'to', 'categoryIdFrom'],
      },
    }),
  ]);
};
