@interrep/db
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

InterRep db

DB utility functions, schemas and models used by InterRep.

Github license NPM version Downloads npm bundle size (scoped) Linter eslint Code style prettier

The @interrep/db package is an internal package that contains utility functions, models and methods used in the system to interact with persistent data, and its purpose is to make InterRep more database-agnostic. InterRep currently uses MongoDB and Mongoose.


🛠 Install

npm or yarn

Install the @interrep/db package with npm:

npm i @interrep/db --save

or yarn:

yarn add @interrep/db

📜 Usage

# connect(mongoUrl: string, errorListener?: (...args: any[]) => void): Promise<boolean>

import { connect } from "@interrep/db"

const { MONGO_URL } = process.env

await connect(MONGO_URL)
// or await connect(MONGO_URL, (error) => console.error(error))

# disconnect(): Promise<boolean>

import { disconnect } from "@interrep/db"

await disconnect()

# clear(): Promise<boolean>

import { clear } from "@interrep/db"

await clear() // Delete all the db entries.

# drop(): Promise<boolean>

import { drop } from "@interrep/db"

await drop() // Drop the db.

# getState(): number

import { getState } from "@interrep/db"

const state = getState()
/*
Connection ready state:

- 0 = disconnected
- 1 = connected
- 2 = connecting
- 3 = disconnecting
*/

You can find the model of each entity on src/<entityName>/<EntityName.model.ts>. Each model has predefined functions and some custom static functions defined on src/<entityName>/<EntityName>.statics.ts. The @interrep/db package also exports types and models of each entity.

Readme

Keywords

none

Package Sidebar

Install

npm i @interrep/db

Weekly Downloads

0

Version

0.9.0

License

MIT

Unpacked Size

57.1 kB

Total Files

49

Last publish

Collaborators

  • cedoor