1.0.5 • Published 2 years ago

better-sql v1.0.5

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

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

1.0.5

2 years ago

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