/NPM-sqlite3-simplifier

NPM package, for SQLite simplifications

Primary LanguageJavaScriptApache License 2.0Apache-2.0

SQLite Simplifier for NodeJS

¿How it works?

This package was made to simplify the SQLite functions (although, their documentation is horrible, so I'm here to help you)

Important Information:

  • The package is totally public (everyone can see the code), located in https://github.com/Vera0011/NPM-sqlite3-simplifier.git
  • The package INCLUDES SQLite3 AND SQLCypher
  • If you liked the package, leave a star in the repository, please!
  • Tha package is made to have different options, that we will see down here

Starting

1- First of all, you need to install the package, like this:

npm i @veraa/npm-sqlite3-simplifier

2- Import in your code the functions (you can just import those you need):

const {databaseLoad, databaseRun, databaseGet, databaseAll, databaseClose, databaseDropTable } = require("@veraa/npm-sqlite3-simplifier");

3- And that's it! The functions are asynchronous, so don't forget to use async / await

Configuration:

  • SQLCypher is activated from default (to encrypt all data).
  • If you want to disable SQLCypher, go to the package.json of the module, and in the options section, change "isCypherEnabled": true to "isCypherEnabled": false.
  • IF YOU USE SQLCypher, change the password, located in package.json of the module, "key" section (you can change it to whatever you want).

Functions, parameters, etc

1-

await databaseLoad(path, databaseName);
/** 
@params
- Path (string)
Path where you want the database to get started

- databaseName (string)
The name you want for your database (set to "database.db" for default)

@Return
- If all is okay, returns 1
- If an error occures, returns 0 and a error message
*/

2-

await databaseRun(sql, params);

/** 
@params
- sql (string)
SQL sentence used. Example: `CREATE TABLE IF NOT EXISTS example (example TEXT)`

- params (array of strings)
If you want to use parameters, for example: [userData, userName], use this parameter. Default is null

@Return
- If all is okay, returns 1
- If an error occures, returns 0 and a error message
*/

3-

await databaseGet(sql, params);

/** 
@params
- sql (string)
SQL sentence used. Example: `INSERT INTO example VALUES (example)`

- params (array of strings)
If you want to use parameters, for example: [userData, userName], use this parameter. Default is null

@Return
- If all is okay, returns the first coincidence found in the database
- If an error occures, returns 0 and a error message
*/

4-

await databaseAll(sql, params);

/** 
@params
- sql (string)
SQL sentence used. Example: `SELECT * FROM example WHERE examle="example"`

- params (array of strings)
If you want to use parameters, for example: [userData, userName], use this parameter. Default is null

@Return
- If all is okay, returns all the coincidences found in the database
- If an error occures, returns 0 and a error message
*/

5-

await databaseClose();

/** 
@Return
- If all is okay, returns 1
- If an error occures, returns 0 and a error message
*/

6-

await databaseDropTable(table);

/** 
@params
- table (string)
Name of the table to drop.

@Return
- If all is okay, returns 1
- If an error occures, returns 0 and a error message
*/