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

const schemaProductList = joi.object({
  name: joi.string().required(),
  platform: joi.string().required(),
  count: joi.number().default(0).allow(0),
});

export const GroupProductList = new ModelApiLoader('group_shopee_product', schemaProductList);

export const loaderIndex = () => {
  return Promise.allSettled([
    GroupProductList.createIndex({
      index: {
        fields: ['name', 'platform'],
      },
    }),
  ]);
};
