{"_id":"@danny270793/myorm","_rev":"3-8eb22e70825b6e46a6cd9cb0a1f80bfa","name":"@danny270793/myorm","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@danny270793/myorm","version":"1.0.0","keywords":["orm","sqlite","typescript","migrations","query builders","active record pattern"],"author":{"url":"https://danny270793.github.io/#/","name":"Danny Vaca","email":"danny270793@gmail.com"},"license":"MIT","_id":"@danny270793/myorm@1.0.0","maintainers":[{"name":"danny270793","email":"danny270793@icloud.com"}],"homepage":"https://github.com/danny270793/myorm#readme","bugs":{"url":"https://github.com/danny270793/layout/issues"},"dist":{"shasum":"c2a5ad0a81733ba2d79dfeb3a0e6c99d334a169f","tarball":"https://registry.npmjs.org/@danny270793/myorm/-/myorm-1.0.0.tgz","fileCount":228,"integrity":"sha512-jHx59H1ZrWN8zPFhAMlEDEZxp8CU9HxNyY1hDdHB0IOqOuHBh/mdmSKh/bAPMHHjuc4SkQhOwQdJvSk4vMzx0w==","signatures":[{"sig":"MEYCIQCLC0lrXsmsOQNqeayDMy72/7zSWD5u398w4yTrYiz1NwIhAML0cJnPfmo6jVYHVSoiJYSIU5lXoCzN3Netn8rRHIFg","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":371401},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"478bafb52cfa8f118e79fdef62737f0ba44f47b4","scripts":{"test":"vitest run","build":"tsc","start":"node examples/basic-usage.js","format":"prettier . --write","example":"npm run build && node dist/examples/basic-usage.js","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"danny270793","email":"danny270793@icloud.com"},"repository":{"url":"git+https://github.com/danny270793/myorm.git","type":"git"},"_npmVersion":"10.8.2","description":"A lightweight, type-safe ORM for SQLite with TypeScript support, featuring migrations, query builders, and an Active Record pattern.","directories":{},"_nodeVersion":"20.18.0","dependencies":{"better-sqlite3":"^12.4.1"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","prettier":"3.6.2","typescript":"^5.9.3","@vitest/coverage-v8":"^3.0.0","@types/better-sqlite3":"^7.6.13"},"_npmOperationalInternal":{"tmp":"tmp/myorm_1.0.0_1761683114578_0.3997275511465517","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@danny270793/myorm","version":"1.0.1","keywords":["orm","sqlite","typescript","migrations","query builders","active record pattern"],"author":{"url":"https://danny270793.github.io/#/","name":"Danny Vaca","email":"danny270793@gmail.com"},"license":"MIT","_id":"@danny270793/myorm@1.0.1","maintainers":[{"name":"danny270793","email":"danny270793@icloud.com"}],"homepage":"https://github.com/danny270793/myorm#readme","bugs":{"url":"https://github.com/danny270793/layout/issues"},"dist":{"shasum":"a9dd802526b6678dc5dfb91b9c8f5db655921e2a","tarball":"https://registry.npmjs.org/@danny270793/myorm/-/myorm-1.0.1.tgz","fileCount":223,"integrity":"sha512-YGVXVRB5ENoByLcG7we9pKXT6fJ5Oj3YcbP2cWJCFJkjGP0W6uprXV4Dhs1ukEbyNqY2zBL/2uwi1Kluq180Tw==","signatures":[{"sig":"MEUCIQCQh4dIP94UQhWZR4BX8aszIy7icje6zezWkoslRLy6BwIgKb9tLY4HLppWi1jdZ9HMZbTIq8g8OI1OdevugZQ77i0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":365787},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3e121c8c11888424e6fde6ca467e7a09523f5d2d","scripts":{"docs":"typedoc","test":"vitest run","build":"tsc","start":"node examples/basic-usage.js","format":"prettier . --write","example":"npm run build && node dist/examples/basic-usage.js","publish":"npm publish --access public","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"danny270793","email":"danny270793@icloud.com"},"repository":{"url":"git+https://github.com/danny270793/myorm.git","type":"git"},"_npmVersion":"10.8.2","description":"A lightweight, type-safe ORM for SQLite with TypeScript support, featuring migrations, query builders, and an Active Record pattern.","directories":{},"_nodeVersion":"20.18.0","dependencies":{"better-sqlite3":"^12.4.1"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","typedoc":"^0.28.14","prettier":"3.6.2","typescript":"^5.9.3","@vitest/coverage-v8":"^3.0.0","@types/better-sqlite3":"^7.6.13","typedoc-plugin-markdown":"^4.9.0"},"_npmOperationalInternal":{"tmp":"tmp/myorm_1.0.1_1761686712787_0.16749197953821482","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@danny270793/myorm","version":"1.0.2","main":"dist/index.js","types":"dist/index.d.ts","author":{"name":"Danny Vaca","email":"danny270793@gmail.com","url":"https://danny270793.github.io/#/"},"repository":{"type":"git","url":"git+https://github.com/danny270793/myorm.git"},"bugs":{"url":"https://github.com/danny270793/layout/issues"},"scripts":{"build":"tsc","start":"node examples/basic-usage.js","example":"npm run build && node dist/examples/basic-usage.js","format":"prettier . --write","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","docs":"typedoc","publish":"npm publish --access public"},"keywords":["orm","sqlite","typescript","migrations","query builders","active record pattern"],"license":"MIT","description":"A lightweight, type-safe ORM for SQLite with TypeScript support, featuring migrations, query builders, and an Active Record pattern.","devDependencies":{"@types/better-sqlite3":"^7.6.13","@vitest/coverage-v8":"^3.0.0","prettier":"3.6.2","typedoc":"^0.28.14","typedoc-plugin-markdown":"^4.9.0","typescript":"^5.9.3","vitest":"^3.0.0"},"dependencies":{"better-sqlite3":"^12.4.1"},"_id":"@danny270793/myorm@1.0.2","gitHead":"3e121c8c11888424e6fde6ca467e7a09523f5d2d","homepage":"https://github.com/danny270793/myorm#readme","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-lXlaL5hj4RV+Mq/qvhRMurzCsnewE+MGFamsyka20mHqba6xMJiIQFLUiaVHlWoYtFIyEwfOnMAAyQM/iuwf8g==","shasum":"538ad1569fa2edd5fb3768586e2683e441269330","tarball":"https://registry.npmjs.org/@danny270793/myorm/-/myorm-1.0.2.tgz","fileCount":223,"unpackedSize":365787,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCx71nI3LCKP8N+PyHKEAOqiBXM6nLyca4Rg1aX/bRP2AIhAKDhknsLxFVoNXrMI3sZNbV7o/ER1OydvemBzqy4oOv5"}]},"_npmUser":{"name":"danny270793","email":"danny270793@icloud.com"},"directories":{},"maintainers":[{"name":"danny270793","email":"danny270793@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/myorm_1.0.2_1761686747928_0.49136562136055506"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-28T20:25:14.512Z","modified":"2025-10-28T21:25:48.326Z","1.0.0":"2025-10-28T20:25:14.762Z","1.0.1":"2025-10-28T21:25:12.981Z","1.0.2":"2025-10-28T21:25:48.145Z"},"bugs":{"url":"https://github.com/danny270793/layout/issues"},"author":{"name":"Danny Vaca","email":"danny270793@gmail.com","url":"https://danny270793.github.io/#/"},"license":"MIT","homepage":"https://github.com/danny270793/myorm#readme","keywords":["orm","sqlite","typescript","migrations","query builders","active record pattern"],"repository":{"type":"git","url":"git+https://github.com/danny270793/myorm.git"},"description":"A lightweight, type-safe ORM for SQLite with TypeScript support, featuring migrations, query builders, and an Active Record pattern.","maintainers":[{"name":"danny270793","email":"danny270793@icloud.com"}],"readme":"# MyORM\n\n[![npm version](https://img.shields.io/npm/v/@danny270793/myorm.svg)](https://www.npmjs.com/package/@danny270793/myorm)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)\n[![Tests](https://img.shields.io/badge/tests-114%20passing-success.svg)](./src/__tests__)\n\nA lightweight, type-safe ORM for SQLite with TypeScript support, featuring migrations, query builders, and an Active Record pattern.\n\n## Features\n\n- 🔒 **Type-safe** - Full TypeScript support with type definitions\n- 🗄️ **SQLite** - Built on better-sqlite3 for fast, synchronous operations\n- 🔄 **Migrations** - Schema versioning and migration tracking with up/down support\n- 🎯 **Active Record Pattern** - Intuitive model-based data access\n- 🔨 **Query Builders** - Fluent API for building complex queries\n- 🏗️ **Schema Builder** - Programmatic table creation with constraints\n- 🔄 **Type Conversions** - Automatic TypeScript ↔ SQLite type mapping\n- ✅ **Well-tested** - 114 tests with comprehensive coverage\n- 📚 **API Documentation** - Complete TypeDoc-generated documentation\n- 📦 **Minimal dependencies** - Only requires better-sqlite3\n- 🎨 **Developer-friendly** - Extensive examples and guides\n\n## Installation\n\n```bash\nnpm install @danny270793/myorm better-sqlite3\nnpm install -D @types/better-sqlite3\n```\n\n## Quick Start\n\n### 1. Define a Model\n\n```typescript\nimport { Model, Column } from '@danny270793/myorm';\n\nclass User extends Model {\n    static readonly tableName = 'users';\n\n    getId(): string | number {\n        return this.id.get();\n    }\n\n    id: Column = new Column('id', 'number');\n    name: Column = new Column('name', 'string');\n    email: Column = new Column('email', 'string');\n    active: Column = new Column('active', 'boolean');\n}\n```\n\n### 2. Create a Migration\n\n```typescript\nimport { Migration, Schema, TableBuilder } from '@danny270793/myorm';\n\nclass CreateUsersTable extends Migration {\n    getMigrationNumber(): number {\n        return 1;\n    }\n\n    up(schema: Schema): void {\n        schema.createTable('users', (table: TableBuilder) => {\n            table.column('id', 'number').primaryKey().autoIncrement();\n            table.column('name', 'string').notNull();\n            table.column('email', 'string').unique();\n            table.column('active', 'boolean').default(true);\n        });\n    }\n\n    down(schema: Schema): void {\n        schema.dropTable('users');\n    }\n}\n```\n\n### 3. Run Migrations\n\n```typescript\nimport { Migrations } from '@danny270793/myorm';\n\nawait Migrations.setup();\n```\n\n### 4. Use the Model\n\n```typescript\n// Create\nconst user = await User.create({\n    name: 'John Doe',\n    email: 'john@example.com',\n    active: true,\n});\n\n// Read\nconst foundUser = await User.find('1');\nconst allUsers = await User.findAll();\n\n// Update\nfoundUser.name.set('Jane Doe');\nawait foundUser.save();\n\n// Delete\nawait foundUser.delete();\n```\n\n## API Reference\n\n### Model\n\nBase class for all models. Provides CRUD operations.\n\n```typescript\nabstract class Model {\n    static async create<T>(data: Record<string, any>): Promise<T>;\n    static async find<T>(id: string): Promise<T>;\n    static async findAll<T>(): Promise<T[]>;\n    async save(): Promise<void>;\n    async delete(): Promise<void>;\n}\n```\n\n### Column\n\nRepresents a database column with type-safe getters and setters.\n\n```typescript\nclass Column {\n    constructor(name: string, type: string);\n    get(): any;\n    set(value: any): void;\n    getName(): string;\n    getType(): string;\n}\n```\n\n### Migration\n\nBase class for database migrations.\n\n```typescript\nabstract class Migration {\n    abstract getMigrationNumber(): number;\n    abstract up(schema: Schema): void;\n    abstract down(schema: Schema): void;\n    async wasApplied(schema: Schema): Promise<boolean>;\n    async apply(schema: Schema): Promise<void>;\n}\n```\n\n### Schema\n\nManages database schema operations and migration tracking.\n\n```typescript\nclass Schema {\n    createTable(tableName: string, callback: (table: TableBuilder) => void): void;\n    dropTable(tableName: string): void;\n    isMigrationApplied(migrationNumber: number): boolean;\n    recordMigration(migrationNumber: number): void;\n}\n```\n\n### TableBuilder\n\nFluent API for building table schemas.\n\n```typescript\nclass TableBuilder {\n    column(name: string, type: string): ColumnBuilder;\n    // Generates CREATE TABLE SQL\n}\n\nclass ColumnBuilder {\n    primaryKey(): this;\n    autoIncrement(): this;\n    unique(): this;\n    notNull(): this;\n    nullable(): this;\n    default(value: any): this;\n}\n```\n\n### Query Builders\n\nBuild SQL queries programmatically.\n\n```typescript\n// SELECT\nconst query = Select.from('users')\n    .where({ field: 'active', operator: '=', value: true })\n    .orderBy('name', 'asc')\n    .limit(10);\n\n// INSERT\nconst query = Insert.into('users').rows({\n    name: 'John',\n    email: 'john@example.com',\n});\n\n// UPDATE\nconst query = Update.table('users')\n    .set({ name: 'Jane' })\n    .where({ field: 'id', operator: '=', value: 1 });\n\n// DELETE\nconst query = Delete.from('users').where({\n    field: 'id',\n    operator: '=',\n    value: 1,\n});\n```\n\n## Advanced Features\n\n### Custom Table Names\n\nBy default, MyORM generates table names from class names. You can override this:\n\n```typescript\nclass User extends Model {\n    static readonly tableName = 'users'; // Explicit table name\n}\n```\n\n### Query Builder Features\n\n- Complex WHERE clauses with multiple operators (`=`, `!=`, `>`, `<`, `>=`, `<=`, `LIKE`)\n- ORDER BY with ASC/DESC\n- LIMIT and OFFSET for pagination\n- WHERE IN for multiple values\n\n### Migration Management\n\nMigrations are tracked in a `migrations` table, ensuring they run only once:\n\n```typescript\n// Check if migration was applied\nconst applied = await migration.wasApplied(schema);\n\n// Apply migration\nawait migration.apply(schema);\n```\n\n### Type Safety\n\nAll models and queries are fully typed, providing IDE autocomplete and compile-time type checking.\n\n## Type Mappings\n\nMyORM automatically maps between TypeScript and SQLite types:\n\n| TypeScript | SQLite  | Notes                     |\n| ---------- | ------- | ------------------------- |\n| `string`   | TEXT    |                           |\n| `number`   | INTEGER |                           |\n| `boolean`  | INTEGER | 0 = false, 1 = true       |\n| `date`     | TEXT    | Stored as ISO 8601 string |\n\n## Examples\n\nSee the `examples/` directory for complete working examples:\n\n- **`1-models-and-crud.ts`** - Model definition and basic CRUD operations\n- **`2-migrations.ts`** - Database migrations with up/down functionality\n- **`3-query-builders.ts`** - Advanced query building with conditions and joins\n- **`4-type-conversions.ts`** - TypeScript to SQLite type conversion examples\n- **`5-basic-usage.ts`** - Complete application example with all features\n\nRun the examples:\n\n```bash\n# Run the main example\nnpm run example\n\n# Run specific examples\nnpm run build\nnode dist/examples/1-models-and-crud.js\nnode dist/examples/2-migrations.js\nnode dist/examples/3-query-builders.js\nnode dist/examples/4-type-conversions.js\n```\n\nFor more details, see the [Examples README](./examples/README.md).\n\n## Testing\n\n```bash\n# Run tests once\nnpm test\n\n# Run tests in watch mode\nnpm run test:watch\n\n# Run tests with coverage\nnpm run test:coverage\n```\n\n## Building\n\n```bash\n# Build TypeScript to JavaScript\nnpm run build\n\n# Format code with Prettier\nnpm run format\n```\n\n## Documentation\n\nGenerate API documentation:\n\n```bash\nnpm run docs\n```\n\nThis generates markdown documentation in the `docs/` directory using TypeDoc.\n\nView the online documentation: [API Documentation](./docs/README.md)\n\n## Project Structure\n\n```\nMyORM/\n├── src/\n│   ├── index.ts                    # Main entry point (barrel file)\n│   └── libraries/\n│       ├── basics/                 # Query builders (Select, Insert, Update, Delete)\n│       ├── models/                 # Model and Column classes\n│       ├── migrations/             # Migration and TableBuilder classes\n│       ├── schema.ts               # Schema management\n│       ├── database.ts             # DatabaseManager singleton\n│       └── logger.ts               # Logging utility\n├── examples/                       # Example applications\n├── src/__tests__/                  # Test suite\n└── docs/                          # Generated API documentation\n```\n\n## Author\n\n**Danny Vaca**\n- Email: danny270793@gmail.com\n- Website: [https://danny270793.github.io](https://danny270793.github.io/#/)\n- GitHub: [@danny270793](https://github.com/danny270793)\n\n## Repository\n\n- **GitHub**: [https://github.com/danny270793/myorm](https://github.com/danny270793/myorm)\n- **Issues**: [https://github.com/danny270793/layout/issues](https://github.com/danny270793/layout/issues)\n- **NPM**: [@danny270793/myorm](https://www.npmjs.com/package/@danny270793/myorm)\n\n## License\n\nMIT License - see [LICENSE](./LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n### Development Setup\n\n1. Clone the repository\n2. Install dependencies: `npm install`\n3. Run tests: `npm test`\n4. Build: `npm run build`\n5. Format code: `npm run format`\n\n","readmeFilename":"README.md"}