All files / web/src/db/schema worksheet-shares.ts

100% Statements 40/40
100% Branches 0/0
100% Functions 0/0
100% Lines 40/40

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 412x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
 
/**
 * Worksheet shares table - stores immutable worksheet configurations for sharing
 *
 * Allows users to create shareable links to specific worksheet configurations.
 * Each share is identified by a short code (e.g., "abc123") for clean URLs.
 *
 * Use cases:
 * - Teacher collaboration (sharing proven worksheets)
 * - Parent resources (sending specific practice worksheets)
 * - Curriculum documentation (maintaining standard configurations)
 * - Bug reports (sharing exact problematic configurations)
 * - Social sharing ("Check out this worksheet!")
 */
export const worksheetShares = sqliteTable('worksheet_shares', {
  /** Short code identifier for URL (e.g., "abc123") - 7 characters, base62 */
  id: text('id').primaryKey(),
 
  /** Type of worksheet: 'addition', 'subtraction', 'multiplication', etc. */
  worksheetType: text('worksheet_type').notNull(),
 
  /** JSON blob containing full worksheet configuration (immutable snapshot) */
  config: text('config').notNull(),
 
  /** Timestamp of creation */
  createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
 
  /** View counter - incremented each time the share is accessed */
  views: integer('views').notNull().default(0),
 
  /** Optional: Creator IP for spam prevention (hashed) */
  creatorIp: text('creator_ip'),
 
  /** Optional: Title/description for the worksheet share */
  title: text('title'),
})
 
export type WorksheetShare = typeof worksheetShares.$inferSelect
export type NewWorksheetShare = typeof worksheetShares.$inferInsert