Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
categoryRepo = new repositoryClass(Category, ctx.dataSource);
itemRepo = new repositoryClass(Item, ctx.dataSource);
if (!hasInclusionResolvers(categoryRepo)) {
throw new Error(
`Repository class "${categoryRepo.constructor.name}" must provide a public "inclusionResolvers" property`,
);
}
const itemsMeta = Category.definition.relations.items;
const itemsResolver = createHasManyInclusionResolver(
itemsMeta as HasManyDefinition,
async () => itemRepo,
);
categoryRepo.inclusionResolvers.set('items', itemsResolver);
await ctx.dataSource.automigrate([Category.name, Item.name]);
}),
);