Deoxys is an flexible, adaptable and type-safe repository pattern implementation for Node.js.
Deoxys encourages you to build your applications such that:
-
Your business logic deals with plain objects or simple entity classes which are decoupled from the specifics of any persistence solution. These entities don't know how or if they are saved in any data stores.
-
Repositories deal with the responsibility of persisting these entities into data stores (SQL, NoSQL, KeyValue stores etc.) through different backends.
To use deoxys, you primarily need:
- The core library, which provides fundamental common APIs for facilitating the repository abstraction:
npm install --save @deoxys/core
// OR
yarn add @deoxys/core
- A persistence backend, which facilitates persisting these repositories in data stores like an SQL database, MongoDB etc.
Currently the only backend available is the knex-backend, which integrates with all major relational databases including Postgres, MySQL, MSSQL etc.
Deoxys test suite currently covers only Postgres and Sqlite.
npm install --save @deoxys/knex-backend
// OR
yarn add @deoxys/knex-backend
// user-repo.ts
import * as knex from "knex";
import {Repository} from "@deoxys/knex-backend";
const usersRepo = Repository({
source: knex("users")
});
usersRepo.insertOne({
id: 1,
name: "Alkazar"
})
usersRepo.find({
name: "Alkazar"
}).then((entity) => {
console.log(entity);
})


