{"_id":"@0xtotem/lorm","_rev":"2-c50d98ffe3a56c90c6db7cde511c7e7c","name":"@0xtotem/lorm","dist-tags":{"latest":"0.0.11"},"versions":{"0.0.1":{"name":"@0xtotem/lorm","version":"0.0.1","keywords":["records","lists","database","orm"],"author":{"name":"bwilytsch"},"license":"MIT","_id":"@0xtotem/lorm@0.0.1","maintainers":[{"name":"bwilytsch","email":"bwilytsch@gmail.com"}],"homepage":"https://github.com/bwilytsch/lorm#readme","bugs":{"url":"https://github.com/bwilytsch/lorm/issues"},"dist":{"shasum":"fc25e849d8a6898697cf52dc24a73d9295fea9ee","tarball":"https://registry.npmjs.org/@0xtotem/lorm/-/lorm-0.0.1.tgz","fileCount":4,"integrity":"sha512-FTknuPMIWTrfWIxRfk/YeYPZqu0zNkWIrgYN/wSTHzm6selz2jyeIJ6wcim+ZJjwZDkIlkmz6lugjBgtN3YC6A==","signatures":[{"sig":"MEUCIBeXrkvnE3GyqUv7+2jBTZ+5keD18Kg7KTJJg18trbA9AiEArGJRrCLCUzng338t2djed2Xjn0b9+oNBCThHUOcsdJ4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35121},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":"./dist/index.js","./package.json":"./package.json"},"gitHead":"ffc04090ac2bfa63bb211478183e764e8a0f7ec8","scripts":{"test":"bun test","build":"tsdown --minify","benchmark":"bun run benchmarks/orderBy.ts"},"_npmUser":{"name":"bwilytsch","email":"bwilytsch@gmail.com"},"repository":{"url":"git+https://github.com/bwilytsch/lorm.git","type":"git"},"_npmVersion":"10.9.0","description":"A library for working with lists of records","directories":{},"_nodeVersion":"22.11.0","dependencies":{"zod":"^3.25.74","neverthrow":"^8.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"mitata":"^1.0.34","tsdown":"^0.12.4","@types/bun":"latest","@faker-js/faker":"^9.8.0","@standard-schema/spec":"^1.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/lorm_0.0.1_1754378570896_0.7694949114024814","host":"s3://npm-registry-packages-npm-production"}},"0.0.11":{"name":"@0xtotem/lorm","version":"0.0.11","description":"A mini-ORM for localStorage with type safety and SQL-inspired API","type":"module","author":{"name":"bwilytsch"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/bwilytsch/lorm.git"},"keywords":["localStorage","mini-orm","orm","browser","client-side","typescript","type-safe"],"publishConfig":{"access":"public"},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"bun test","benchmark":"bun run benchmarks/orderBy.ts","build":"tsdown --minify"},"devDependencies":{"@faker-js/faker":"^9.8.0","@standard-schema/spec":"^1.0.0","@types/bun":"latest","mitata":"^1.0.34","tsdown":"^0.12.4"},"peerDependencies":{"typescript":"^5"},"dependencies":{"neverthrow":"^8.2.0","zod":"^3.25.74"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"module":"./dist/index.js","_id":"@0xtotem/lorm@0.0.11","gitHead":"ead5e8ad54424521d1f54c1503e33c8994490746","bugs":{"url":"https://github.com/bwilytsch/lorm/issues"},"homepage":"https://github.com/bwilytsch/lorm#readme","_nodeVersion":"22.11.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-IHX4UdUW2GlP6aFcczAF8GruhphJaasyKu9nyG+c4p+bEokAmPPoBBc0CgV0ydH0JovR0wXOyOrIEoFNK68/UA==","shasum":"98906353e7534ba6c1fba9697de232932c311f7d","tarball":"https://registry.npmjs.org/@0xtotem/lorm/-/lorm-0.0.11.tgz","fileCount":4,"unpackedSize":35719,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDvhkyjeCsezgtnxdJ6jaWySE6UVV4cXQqwXFMm3I9YxgIhAMzsOLcYzPA9i3Yv8xoAmO4iCGYeL1azNyinvN6baUT9"}]},"_npmUser":{"name":"bwilytsch","email":"bwilytsch@gmail.com"},"directories":{},"maintainers":[{"name":"bwilytsch","email":"bwilytsch@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lorm_0.0.11_1754379119070_0.667106640189798"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-05T07:22:50.842Z","modified":"2025-08-05T07:31:59.437Z","0.0.1":"2025-08-05T07:22:51.095Z","0.0.11":"2025-08-05T07:31:59.239Z"},"bugs":{"url":"https://github.com/bwilytsch/lorm/issues"},"author":{"name":"bwilytsch"},"license":"MIT","homepage":"https://github.com/bwilytsch/lorm#readme","keywords":["localStorage","mini-orm","orm","browser","client-side","typescript","type-safe"],"repository":{"type":"git","url":"git+https://github.com/bwilytsch/lorm.git"},"description":"A mini-ORM for localStorage with type safety and SQL-inspired API","maintainers":[{"name":"bwilytsch","email":"bwilytsch@gmail.com"}],"readme":"# LORM (localStorage ORM)\n\nA lightweight mini-ORM for localStorage with TypeScript support and SQL-inspired API.\n\n**⚠️ This project is in active development and not yet ready for production use.**\n\n## Introduction\n\nLORM is a minimalist Object-Relational Mapping (ORM) library for JavaScript/TypeScript that persists data to localStorage. It provides a simple, type-safe API for working with structured data in the browser, inspired by SQL syntax and modern ORM libraries.\n\n## Features\n\n- **localStorage persistence**: Data persists across browser sessions using localStorage\n- **In-memory operations**: Fast operations with cached data in JavaScript Maps\n- **Type-safe schemas**: Built-in schema validation with Zod\n- **SQL-inspired API**: Familiar query methods like `select()`, `insert()`, and `delete()`\n- **Filtering capabilities**: Powerful `where` clauses with object syntax or functional predicates\n- **Browser-first**: Designed specifically for client-side JavaScript applications\n- **Performance focused**: Optimized for speed with benchmarking included\n\n## Performance\n\nLORM is optimized for localStorage-backed operations, with different query strategies for various data sizes:\n\n[benchmark](benchmark.md)\n\n## Installation\n\n```bash\n# Using bun\nbun add 0xtotem/lorm\n\n# Using npm\nnpm install 0xtotem/lorm\n\n# Using yarn\nyarn add 0xtotem/lorm\n```\n\n## Example Usage\n\n### Basic Setup\n\n```typescript\nimport { lorm, table, schema, string, number } from \"@0xtotem/lorm\";\n\n// Define your schema using re-exported Zod types\nconst userSchema = schema({\n  id: string(),\n  name: string(),\n  age: number(),\n});\n\n// Or use Zod directly\nimport { z } from \"zod\";\nconst userSchemaZod = z.object({\n  id: z.string(),\n  name: z.string(),\n  age: z.number(),\n});\n\n// Initialize the ORM\nconst db = lorm(\"my-app\");\n\n// Create a table\nconst users = table(\"users\", userSchema);\n```\n\n### Insert Data\n\n```typescript\n// Insert a new user\ndb.insert(users).values({\n  id: \"1\",\n  name: \"John Doe\",\n  age: 30\n});\n```\n\n### Query Data\n\n```typescript\n// Get all users\nconst allUsers = await db.select().from(users);\n\n// Filter users with object syntax\nconst filteredUsers = await db.select().from(users).where({ name: \"John Doe\" });\n\n// Filter users with functional predicate\nimport { eq } from \"lorm\";\nconst johnDoe = await db.select().from(users).where(eq(\"name\", \"John Doe\"));\n\n// Limit results\nconst limitedUsers = await db.select().from(users).limit(5);\n```\n\n### Delete Data\n\n```typescript\n// Delete by condition\nawait db.delete(users).where(eq(\"id\", \"1\"));\n\n// Delete with returning deleted items\nconst deletedUsers = await db.delete(users).where(eq(\"id\", \"1\")).returning();\n```\n\n### Multiple Tables\n\n```typescript\nimport { schema, string, boolean } from \"lorm\";\n\nconst todoSchema = schema({\n  id: string(),\n  title: string(),\n  completed: boolean(),\n});\n\nconst todos = table(\"todos\", todoSchema);\n\n// Insert into todo table\ndb.insert(todos).values({\n  id: \"1\",\n  title: \"Buy groceries\",\n  completed: false\n});\n\n// Query both tables\nconst allUsers = await db.select().from(users);\nconst allTodos = await db.select().from(todos);\n```\n\n## API Reference\n\n### Core Functions\n\n- `lorm(namespace: string)`: Creates a new ORM instance\n- `table(name: string, schema: ZodType<T>)`: Creates a new table with the specified schema\n- `schema(obj)`: Re-exported Zod object schema creator\n- `string()`, `number()`, `boolean()`: Re-exported Zod primitive types\n\n### ORM Methods\n\n- `db.select().from(table)`: Start a query to select data from a table\n- `db.insert(table).values(data)`: Insert data into a table\n- `db.delete(table).where(condition)`: Delete data from a table\n\n### Query Builder Methods\n\n- `.where(condition)`: Filter results by condition\n- `.limit(n)`: Limit results to n items\n- `.limitFilterSlice(n)`: Alternative limit implementation for specific use cases\n\n### Filter Functions\n\n- `eq(field, value)`: Create a predicate to check field equality\n\n### Option Pattern\n\n- `some(value)`: Create a Some instance with a value\n- `none()`: Create a None instance for null values\n- `Option<T>`: Type representing either Some<T> or None\n\n## Dependencies\n\n- [Zod](https://github.com/colinhacks/zod): Schema definition and validation (re-exported for convenience)\n- [Neverthrow](https://github.com/supermacro/neverthrow): Error handling utilities\n\n## Development\n\nThis project was created using `bun init` in [Bun](https://bun.sh) v1.2.4.\n\n### Running Tests\n\n```bash\nbun test\n```\n\n### Running Benchmarks\n\n```bash\nbun run benchmark.ts\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}