@@ -288,11 +288,67 @@ type CreateZeroSchema<
288288} ;
289289
290290/**
291- * Create a Zero schema from a Drizzle schema.
291+ * Create a Zero schema from a Drizzle schema. This function transforms your Drizzle ORM schema
292+ * into a Zero schema format, handling both direct relationships and many-to-many relationships.
293+ *
294+ * The function allows you to:
295+ * - Select which tables to include in the Zero schema
296+ * - Configure column types and transformations
297+ * - Define many-to-many relationships through junction tables
298+ * - Automatically map foreign key relationships
292299 *
293- * @param schema - The Drizzle schema to create a Zero schema from.
294- * @param schemaConfig - The configuration for the Zero schema.
295- * @returns The generated Zero schema.
300+ * @param schema - The Drizzle schema to create a Zero schema from. This should be your complete Drizzle schema object
301+ * containing all your table definitions and relationships.
302+ * @param schemaConfig - Configuration object for the Zero schema generation
303+ * @param schemaConfig.version - Schema version number for tracking changes
304+ * @param schemaConfig.tables - Specify which tables and columns to include in sync
305+ * @param schemaConfig.manyToMany - Optional configuration for many-to-many relationships through junction tables
306+ * @returns A Zero schema containing tables and their relationships
307+ *
308+ * @example
309+ * ```typescript
310+ * import { integer, pgTable, serial, text, varchar } from 'drizzle-orm/pg-core';
311+ * import { relations } from 'drizzle-orm';
312+ * import { createZeroSchema } from 'drizzle-zero';
313+ *
314+ * // Define Drizzle schema
315+ * const users = pgTable('users', {
316+ * id: serial('id').primaryKey(),
317+ * name: text('name'),
318+ * });
319+ *
320+ * const posts = pgTable('posts', {
321+ * id: serial('id').primaryKey(),
322+ * title: varchar('title'),
323+ * authorId: integer('author_id').references(() => users.id),
324+ * });
325+ *
326+ * const usersRelations = relations(users, ({ one }) => ({
327+ * posts: one(posts, {
328+ * fields: [users.id],
329+ * references: [posts.authorId],
330+ * }),
331+ * }));
332+ *
333+ * // Create Zero schema
334+ * const zeroSchema = createZeroSchema(
335+ * { users, posts, usersRelations },
336+ * {
337+ * version: 1,
338+ * tables: {
339+ * users: {
340+ * id: true,
341+ * name: true,
342+ * },
343+ * posts: {
344+ * id: true,
345+ * title: true,
346+ * authorId: true,
347+ * },
348+ * },
349+ * }
350+ * );
351+ * ```
296352 */
297353const createZeroSchema = <
298354 const TDrizzleSchema extends Record < string , unknown > ,
0 commit comments