![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
nukak-sqlite
Advanced tools
flexible and efficient ORM, with declarative JSON syntax and smart type-safety
The perfectionistic ORM for TypeScript and modern JavaScript
ideated to be fast, safe, and simple to plug into any application. Inspired by others such as TypeORM and Mongo driver.
JSON
allowing the queries to be transported across platforms with ease.TypeScript
so it auto-completes and validates the queries, allowing it to infer the appropriate operators on any level of the queries, including the relations and their fieldsOOP
(Object Oriented Programming) and FP
(Functional Programming).transactions
for flexibility, and connection pooling
for scalability.ESM
is natively supported by Node.js 12 and later.API
and transparently transforming queries according to the configured database.
Install the core package:
npm install nukak --save
Install one of the specific adapters for your database:
Database | Driver | Nukak Adapter |
---|---|---|
MySQL | mysql2 | nukak-mysql |
MariaDB | mariadb | nukak-maria |
SQLite | sqlite sqlite3 | nukak-sqlite |
PostgreSQL | pg | nukak-postgres |
MongoDB | mongodb | nukak-mongo |
For example, for Postgres
:
npm install pg nukak-postgres --save
Additionally, your tsconfig.json
may need the following flags:
"target": "es2020",
"experimentalDecorators": true,
"emitDecoratorMetadata": true
A default querier-pool can be set in any of the bootstrap files of your app (e.g. in the server.ts
).
import { setQuerierPool } from 'nukak';
import { PgQuerierPool } from 'nukak-postgres';
export const querierPool = new PgQuerierPool(
{
host: 'localhost',
user: 'theUser',
password: 'thePassword',
database: 'theDatabase',
},
// optionally, a logger can be passed to log the generated SQL queries
{ logger: console.log }
);
// the default querier pool that `nukak` will use
setQuerierPool(querierPool);
Take any dump class (aka DTO) and annotate it with the decorators from nukak/entity
.
import { v4 as uuidv4 } from 'uuid';
import { Id, Field, Entity } from 'nukak/entity';
/**
* any class can be annotated with this decorator to make it works as
* an entity.
*/
@Entity()
export class User {
/**
* an entity should specify an ID Field, its name and type are automatically detected.
* the `onInsert` property can be used to specify a custom mechanism for
* auto-generating the primary-key's value when inserting.
*/
@Id({ onInsert: uuidv4 })
id?: string;
/**
* the properties of the class can be annotated with this decorator so they
* are interpreted as a column, its name and type are automatically detected.
*/
@Field()
name?: string;
@Field()
email?: string;
@Field()
password?: string;
}
import { getQuerier } from 'nukak';
import { User } from './shared/models/index.js';
async function findLastUsers(limit = 10) {
const querier = await getQuerier();
const users = await querier.findMany(User, {
$project: ['id', 'name', 'email'],
$sort: { createdAt: -1 },
$limit: limit,
});
await querier.release();
return users;
}
async function createUser(body: User) {
const querier = await getQuerier();
const id = await querier.insertOne(User, body);
await querier.release();
return id;
}
Learn more about nukak
at its website https://nukak.org
FAQs
flexible and efficient ORM, with declarative JSON syntax and smart type-safety
The npm package nukak-sqlite receives a total of 7 weekly downloads. As such, nukak-sqlite popularity was classified as not popular.
We found that nukak-sqlite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.