@comic-collector/comics-dao

comics-dao

The comics-dao project consists of DAOs (Database Access Objects) for interacting with the comics-db. Written entirely in Typescript, it also contains types for every DAO. The goal of the project is to provide complete CRUD functionality for the comics-db.

You can install comics-dao from the GitLab Package Registry.

To use GitLab Package Registry:

Create or add to .npmrc:

@comic-collector:registry=https://gitlab.com/api/v4/projects/61516411/packages/npm/

Run:

npm add @comic-collector/comics-dao:1.0.0

or

Add to package.json:


"dependencies": {
"@comic-collector/comics-dao": "^1.0.0"
}

Create a .env file:

HOST=YOUR_DB_IP_ADDR
PORT=YOUR_DB_PORT
USER=YOUR_DB_USER
PASSWORD=YOUR_DB_PASSWORD
DATABASE=YOUR_DB_NAME

Create a comics_db.ts file:

class ComicsDB extends ComicsDAO {
protected initializeKnexDb(): Knex {
return knex({
client: 'pg',
connection: {
host: process.env.HOST,
port: process.env.PORT,
user: process.env.USER,
password: process.env.PASSWORD,
database: process.env.DATABASE,
},
});
}
}

Read from database:

import {ComicsDB} from "./comics_db";

const comicsDb: ComicsDB = new ComicsDB();
const comics: Comic[] = await comicsDb.comics.getComics();

This project is licensed under the MIT License - see the LICENSE file for details.