Registry / database / slife
library1.1.15jsnpmunverified

Slife is a small MySQL ORM for Node.js beginners, currently at version 1.1.15 with an unknown release cadence (appears sporadically updated). Key differentiators: supports query chaining (select, insert, update, delete), TypeScript generics for auto-completion, union queries, and raw SQL. Compared to alternatives like Sequelize or TypeORM, Slife is minimal and has no active community. Its peer dependency is the mysql package (npm mysql).

npm install slife
INSTALL
IMPORT
SIG · SLIFE
S
slife
databasejavascriptv1.1.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (Slife class)
import Slife from 'slife'
const { Slife } = require('slife')
ESM export is default; CommonJS require('slife') also works.
require (CommonJS)
const Slife = require('slife')
const { default: Slife } = require('slife')
CommonJS require returns the Slife class directly.
TypeScript type usage
type User = { name: string; age: number }; const db = new Slife({...}); const users = await db.select<User>('*').from('users').run();
const users: User[] = await db.select('*').from('users');
TypeScript users must call .run() and can use generics; omitting .run() causes errors.

Shows instantiation, table creation, insert, select with where clause, and closing the connection.

import Slife from 'slife'; const db = new Slife({ host: 'localhost', database: 'my_database', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', port: 3306 }); const createTable = await db.createTable('users', { id: 'INT AUTO_INCREMENT PRIMARY KEY', name: 'VARCHAR(255)', age: 'INT' }); await db.insert({ name: 'Alice', age: 30 }).into('users'); const rows = await db.select('*').from('users').where('age', '>', 25).run(); console.log(rows); db.end();
Debug
Known issues
gotchaTypeScript users must call .run() at the end of query chains (select, insert, update, delete) to execute the query.
fix
Always append .run() to query chains when using TypeScript.
affects: >=1.0.0
deprecatedThe package has not been updated since 2022 and has no TypeScript definitions officially shipped; types are declared via JSDoc or ambient declarations.
fix
Consider using TypeORM or Sequelize for active support.
affects: <=1.1.15
gotchaThe package depends on the `mysql` npm package (not mysql2), which has known issues with connection handling and is less modern.
fix
If using mysql2, you may need to adjust connection parameters or use a different ORM.
affects: >=1.0.0
Errors
Common errors & fixes
Property 'run' does not exist on type '...'
TypeScript users forgot to include .run() at the end of the query chain.
fix
Add .run() after the query chain: await db.select('*').from('table').run();
Slife is not a constructor
Importing the package incorrectly (e.g., using named import instead of default).
fix
Use const Slife = require('slife') or import Slife from 'slife'.
Cannot find module 'slife' or its corresponding type declarations.
TypeScript cannot find type definitions for slife; the package does not ship .d.ts files.
fix
Create a global.d.ts file with declare module 'slife'; or use @ts-ignore.
Upgrade
Version history
1.1.15latest on npm
Audit
Dependencies
mysqlrequiredpeer dependency for MySQL connection
Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
packageslife
slife — npm install slife · libregistry