1.0.4 • Published 2 years ago

zerotime v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

zerotime

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

Example Usage

Consider the following pets table:

nameownerspeciessexbirthdeath
DreadBobbird\N1997-04-11\N
ScottCostaslion\N1992-12-09\N
PirateBosonlion\N1980-04-15\N
RodgersJohnsontiger\N1991-05-03\N
SteveRobertsalligator\N2001-11-01\N
BushemiTwizzlercrocodile\N2010-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()

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago