Home / Function/ checkSoftRelations() — drizzle-orm Function Reference

checkSoftRelations() — drizzle-orm Function Reference

Architecture documentation for the checkSoftRelations() function in softRelations.test.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  69972cf0_6d92_970f_1c6a_6f6a5fdd1e71["checkSoftRelations()"]
  0c76d57a_c3c3_e7f0_3e17_94521703ac01["softRelations.test.ts"]
  69972cf0_6d92_970f_1c6a_6f6a5fdd1e71 -->|defined in| 0c76d57a_c3c3_e7f0_3e17_94521703ac01
  style 69972cf0_6d92_970f_1c6a_6f6a5fdd1e71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/tests/mysql/softRelationsTest/softRelations.test.ts lines 193–231

const checkSoftRelations = (
	customers: (typeof schema.customers.$inferSelect)[],
	details: (typeof schema.details.$inferSelect)[],
	employees: (typeof schema.employees.$inferSelect)[],
	orders: (typeof schema.orders.$inferSelect)[],
	products: (typeof schema.products.$inferSelect)[],
	suppliers: (typeof schema.suppliers.$inferSelect)[],
) => {
	// employees soft relations check
	const employeeIds = new Set(employees.map((employee) => employee.id));
	const employeesPredicate = employees.every((employee) =>
		employee.reportsTo !== null && employeeIds.has(employee.reportsTo)
	);
	expect(employeesPredicate).toBe(true);

	// orders soft relations check
	const customerIds = new Set(customers.map((customer) => customer.id));
	const ordersPredicate1 = orders.every((order) => order.customerId !== null && customerIds.has(order.customerId));
	expect(ordersPredicate1).toBe(true);

	const ordersPredicate2 = orders.every((order) => order.employeeId !== null && employeeIds.has(order.employeeId));
	expect(ordersPredicate2).toBe(true);

	// product soft relations check
	const supplierIds = new Set(suppliers.map((supplier) => supplier.id));
	const productsPredicate = products.every((product) =>
		product.supplierId !== null && supplierIds.has(product.supplierId)
	);
	expect(productsPredicate).toBe(true);

	// details soft relations check
	const orderIds = new Set(orders.map((order) => order.id));
	const detailsPredicate1 = details.every((detail) => detail.orderId !== null && orderIds.has(detail.orderId));
	expect(detailsPredicate1).toBe(true);

	const productIds = new Set(products.map((product) => product.id));
	const detailsPredicate2 = details.every((detail) => detail.productId !== null && productIds.has(detail.productId));
	expect(detailsPredicate2).toBe(true);
};

Domain

Subdomains

Frequently Asked Questions

What does checkSoftRelations() do?
checkSoftRelations() is a function in the drizzle-orm codebase, defined in drizzle-seed/tests/mysql/softRelationsTest/softRelations.test.ts.
Where is checkSoftRelations() defined?
checkSoftRelations() is defined in drizzle-seed/tests/mysql/softRelationsTest/softRelations.test.ts at line 193.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free