node-dbal-sqlite

0.1.3 • Public • Published

node-dbal-sqlite

Entity oriented DBAL for NodeJS to SQLite This means that you communicate with the database using whole entities as the primitives, instead of data in records.

How it works

The library's exposes a single class that allows access to the data using the repository pattern. This class assumes that all tables store data in columns that directly align with the key value value pairs of data objects, so one row in a table directly corresponds to one entity and the columns represent the key for the values in the row.

How to install

npm install node-dbal-sqlite

How to use

import EntityRepository from 'node-dbal-sqlite';

var repository = new EntityRepository({
file
}:{
  file:string
}, {
dbms, table, pk, converters}: {
  dbms:string;
  table:string;
  pk:string;
  converters:any;
});

Repository functions

findByPk(pk: number | string, txn: any, cb: (err: Error, record: any) => void): void;

findAll(orderBy: string, offset: number, limit: number, txn: any, cb: (err: Error, records: any[]) => void): void;

find(criteria: any, orderBy: string, offset: number, limit: number, txn: any, cb: (err: Error, records: any[]) => void): void;

insert(values: any, txn: any, cb: (err: Error, records: any[], ctx: {
    lastPk: number;
}) => void): void;

updateAll(values: any, txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

updateByPk(pk: number | string, values: any, txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

update(criteria: any, values: any, txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

removeAll(txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

removeByPk(pk: string | number, txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

remove(criteria: any, txn: any, cb: (err: Error, records: any[], ctx: any) => void): void;

countAll(txn: any, cb: (err: Error, value: number) => void): void;

count(criteria: any, txn: any, cb: (err: Error, value: number) => void): void;

beginTransaction(cb: (err: Error, txn: any) => void): void;

commitTransaction(txn: any, cb: (err: Error) => void): void;

rollbackTransaction(txn: any, cb: (err: Error) => void): void;

client: {
    beginTransaction(cb: (err: Error, txn: any) => void): void;
    rollbackTransaction(txn: any, cb: (err: Error) => void): void;
    commitTransaction(txn: any, cb: (err: Error) => void): void;
    exec(queryType: string, sql: string, parameters: any[], txn: any, cb: (err: Error, rows: any[], ctx: any) => void): void;
};

License

LGPL

Dependencies (2)

Dev Dependencies (2)

Package Sidebar

Install

npm i node-dbal-sqlite

Weekly Downloads

1

Version

0.1.3

License

LGPL-3.0

Last publish

Collaborators

  • ahami3000