Kiss-ORM is a minimal, opinionated ORM for TypeScript that enforces explicit SQL usage without a query builder. It uses tagged template literals (sql tag) to safely parameterize queries, preventing SQL injection. Compatible with PostgreSQL (via pg), MySQL (experimental), and SQLite (experimental). Current stable version is 2.0.3. Follows the data-mapper pattern with immutable models and no magic — no implicit database operations. Fully tested with TypeScript types included. Suitable for developers who want full SQL expressiveness with security and simplicity.
npm install kiss-ormNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a PostgreSQL connection, defines a User model, and creates a repository to fetch a user by primary key.
Always wrap SQL strings with the `sql` tagged template literal. Example: `db.query(sql\`SELECT * FROM users WHERE id = ${id}\`)`Use `null` union types for nullable columns in your model class properties.
Prefer PgSqlDatabase for production use. For MySQL or SQLite, be prepared for API changes.
When upgrading from v1, rename `connection: db` to `database: db` in the super() call.
Pass an object with an `info` method (and optionally `warn`, `error`) to the database constructor: `new PgSqlDatabase({...}, { info: console.log })`Expect methods like `get`, `search` to return objects that match the model's shape but are not instances of the model class.
Install the package: `npm install kiss-orm` and ensure imports use the package name, not a relative path.
Ensure you instantiate the database class (e.g., `new PgSqlDatabase({...})`) and not just the config object.Add all columns (including primary key) with `readonly` modifier and proper types (including `| null` for nullable columns).
Wrap the query string with the imported `sql` tag: `db.query(sql\`SELECT * FROM users WHERE id = ${id}\`)`