# zerotime

> Contains wrapper methods that help you work with a MySQL database.

Latest version **1.0.4** (published 2022-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install zerotime
pnpm add zerotime
yarn add zerotime
bun add zerotime
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-05-29 |
| First published | 2022-05-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | ssepac |

## Links

- npm: https://www.npmjs.com/package/zerotime
- npm.io page: https://npm.io/package/zerotime

## Dependencies (3)

- [dotenv](https://npm.io/package/dotenv.md) ^16.0.1
- [mysql2](https://npm.io/package/mysql2.md) ^2.3.3
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0

## Recent versions

- 1.0.4 (latest) — 2022-05-29
- 1.0.3 — 2022-05-29
- 1.0.2 — 2022-05-29
- 1.0.1 — 2022-05-29
- 1.0.0 — 2022-05-29

## README

# zerotime
Contains wrapper methods that help you work with a MySQL database.

## Example Usage

Consider the following *pets* table:

|name   |owner  |species |sex      |birth|death     |
|-------|-------|--------|---------|-----|----------|
|Dread  |Bob    |bird    |\N       |1997-04-11|\N        |
|Scott  |Costas |lion    |\N       |1992-12-09|\N        |
|Pirate |Boson  |lion    |\N       |1980-04-15|\N        |
|Rodgers|Johnson|tiger   |\N       |1991-05-03|\N        |
|Steve  |Roberts|alligator|\N       |2001-11-01|\N        |
|Bushemi|Twizzler|crocodile|\N       |2010-01-03|\N        |

First, get an instance of zerotime:
```
const mysql = require("mysql2");
const createZerotime = require("zerotime");
const connection = mysql.createConnection({
  host: <host>,
  user: <user>,
  password: <your_password>,
  database: <your_database_name>,
});

const zerotime = await createZerotime(connection, <your_table_name>);
```

Methods are automatically created when zerotime is initialized that include your tables fields in them. Consider the following calls below.

### Get all records

`const records = await zerotime.find()`

### Get all records where species type is *lion*:

`const records= await zerotime.getSpecies("lion").find()`

### Get all records where the species is *lion* and name is *Costas*

`const records = await zerotime.getOwner("Costas").getSpecies("lion").find()`

### Add to your database

```
const testObj = {
  name: "Teena",
  owner: "Garrison",
  species: "Tiger",
  sex: "F",
  birth: "1972-01-01"
}

await zerotime.add(connection, testObj)
  ```

### Populate database from a CSV file

`const result = await zerotime.addFromCsv(connection, "file.csv")`

### Cleaning up

At the end of your program be sure to call the following to end your session:

`zerotime.kill()`

---
_Source: https://npm.io/package/zerotime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
