0.9.0 • Published 3 years ago

@interrep/db v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.

0.9.0

3 years ago

0.3.0

4 years ago

0.7.2

4 years ago

0.6.3

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.6.2

4 years ago

0.6.4

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.7.0

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.2.0

4 years ago