JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q41497F
  • License MIT

Easy SQLite ODM for Node.js with TypeScript support

Package Exports

  • sqlite.easy
  • sqlite.easy/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sqlite.easy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sqlite.easy

A simple and lightweight ORM built on top of SQLite for quick and easy database operations in Node.js.

Features

  • Easy model creation with a simple schema definition.
  • Supports CRUD operations: create, find, findOne, update, and delete.
  • Type mapping for common JavaScript types (String, Number, Date, etc.).
  • Works with both JavaScript and TypeScript.

Installation

npm install sqlite.easy

Quick Start

1. Create a model

import db from "sqlite.easy";

const User = db.model("users", {
  id: String,
  name: String,
  age: Number,
  email: String,
  createdAt: Date
});

export default User;

For TS

import db from "sqlite.easy";

type UserType = {
  id: string;
  name: string;
  age: number;
  email: string;
  createdAt: Date;
};

const User = db.model<UserType>("users", {
  id: String,
  name: String,
  age: Number,
  email: String,
  createdAt: Date
});

export default User as ReturnType<typeof db.model<UserType>>;

2. Use the model in your code

Import your model

import User from "./models/user.js";

Get all users

const data = User.find();
console.log(data);

Get users with specific conditions

User.find({ age: 28 });

Create a new user

User.create({
  id: "01234567890",
  name: "Mazen",
  age: 18,
  email: "admin@maz1ndev.xyz",
  createdAt: new Date()
});

Get a single user

User.findOne({ id: "01234567890" });

Update a user

User.update({ id: "01234567890" }, { age: 20 });

Delete a user

User.delete({ id: "01234567890" });

Notes

  • All CRUD methods return synchronous results since SQLite operations are fast and run in-process.
  • Models automatically create the table if it does not exist.

Author

👨‍💻 iimazin11 📂 GitHub: https://github.com/iimazin11