Quickly setup embedded database in SQLite Deno/Typescript/Web

Quickly setup embedded database in SQLite Deno/Typescript/Web

Simple Little ORM for SQLite Very small Object-relational mapper (bare essential) to quickly setup embedded database in SQLite Deno/Typescript/Web.

SmallORM SQLite

Simple Little ORM for SQLite Very small Object-relational mapper (bare essential) to quickly setup embedded database in SQLite Deno/Typescript/Web.

Learn By Examples

import {
  SmallSQLiteORM,
  SmallSQLiteTable,
} from "https://deno.land/x/smallorm_sqlite/mod.ts";

// extend SmallSQLiteTable on your model
// it will add an incremental id by default
export class User extends SmallSQLiteTable {
  userName = "";
  address = "";
  active = false;
  age = 18;
}

export class AnotherTable extends SmallSQLiteTable { }

const orm = new SmallSQLiteORM(
  "test.db", // Name of the db file
  [User, AnotherTable], // All models to Map
  { bool: false, int: 0, str: "" }  // DEFAULT values for all types
);

const user = new User();

user.address = "Denoland 12";
user.userName = "Joe Deno";
user.active = true;
orm.save(user);

console.log(user.id); // Joe now has an id of 1 in our DB

for (let i = 0; i < 5; i++) {
  orm.save(new User()); // Add some more users...
}

console.log(
  orm.count(User),
); // Shows 6 total users in the db

let i = 0;
for (const u of orm.findMany(User)) {
  u.age = 18 + (i++);
  orm.save(u); // Update the age of all our users
}

console.log(
  orm.countBy(User, "age > ?", [21]),
); // Only 2 users are now older than 21

const users = orm.findMany(User, "id > ?", [0], 1, 4); // Returns only 1 (LIMIT) user on OFFSET 4

orm.delete(users[0]); // Removed user row from the DB

Documentation

View it online at doc.deno.land

Extra Features

  • Automatically CREATE TABLE when database file is initialized
  • Automatically ALTER TABLE when model class is changed (only ADD COLUMN)

Download Details:

Author: cybertim

Source Code: https://github.com/cybertim/SmallSQLiteORM

deno nodejs node javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings