0.1.12 • Published 7 months ago

orm-postgres v0.1.12

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

orm-postgres

This project is a typescript ORM that integrates with sqlite3.

Installation:

NPM:

npm init -y
npm install orm-postgres

YARN:

yarn init
yarn add orm-postgres

dbManager:

The class dbManager provides a method to create a db.sqlite3 database, connect to it using package sqlite3, and provide a method that implements the factory design pattern to initiate instance of the EntityManager, A simple example of how to make use of it:

import { EntityInterface, DbManager } from "orm-postgres";

interface UserModal extends EntityInterface {
    name: string;
    email: string;
    password: string;
}

const dbManager = new DbManager({ logs: false });

//creates db.sqlite3 file if it doesn't exist, and initiates a connection to the db
await dbManager.initDB();

//create an entity manager from the interface UserModal, with table name "User"
const UserManager = dbManager.getEntityManager<UserModal>("User");

[
    { name: "John", email: "fez", password: "fez" },
    { name: "John", email: "elvis", password: "elvis" },
].forEach(async (user) => {
    await UserManager.save(user);
});

await UserManager.delete({name: "John"});

await UserManager.find({{name: "John"}}, async (users: UserModal[]) => {
    console.log(users);
});
0.1.12

7 months ago

0.1.11

7 months ago

0.1.10

7 months ago

0.1.9

7 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

7 months ago

0.1.5

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago