better-sql

1.0.5 • Public • Published

Better SQL - First version

The module has just been made. Please be patient, updates are coming

Install

$ npm install better-sql

Use

;(async () => {
    // REQUIRE THE MODULE
    const BetterSQL = require("better-sql");

    // CREATING INSTANCE AND CONNECTING TO DATABASE
    const bsql = await new BetterSQL({
        cache: true, // Cache the sql database
        autoFetch: false, // Auto fetch every request
        fetchAll: true, // Fetch all data from database when connected
        id_name: "id" // The name of your database elements primary keys
    }).connect({
        user: "root", // Your database user username,
        password: "root-password", // Your database user password
        database: "root-db", // The name of the database you want to work with
        host: "localhost" // The host of your database
    });
    // BetterSQL is now ready to be used
})();

Exemples

Create table

const table = await bsql.tables.create("table_name");
await table.fields.add({
    name: "username",
    type: "VARCHAR",
    size: 255,
    unique: true
});

Delete Table

Please notice that deleting table from cache will not edit the sql database

await bsql.tables.cache.get("table_name").delete();

Get Data

// These functions are returning a Data Object
await bsql.tables.cache.get("table_name").data.cache.get("id");
// OR
await bsql.tables.cache.get("table_name").data.cache.find(data => data.username == "billy_the_kid");

Delete data

Please notice that deleting data from cache will not edit the sql database

await bsql.tables.cache.get("table_name").data.cache.get("id").delete();

Join our Discord for more, and for help

Package Sidebar

Install

npm i better-sql

Weekly Downloads

3

Version

1.0.5

License

ISC

Unpacked Size

15.5 kB

Total Files

9

Last publish

Collaborators

  • aeziotech