[go: up one dir, main page]

rhino.db
TypeScript icon, indicating that this package has built-in type declarations

4.8.0 • Public • Published

rhino.db

import { Column, ColumnDataType, Database, Table } from "..";

const db = new Database()

const table = new Table("users")
    .addColumns(
        [
            new Column()
            .setName('id')
            .setPrimary(true)
            .setType(ColumnDataType.TEXT),
            new Column()
            .setName('swords')
            .setType(ColumnDataType.INTEGER)
            .setDefault(0),
            new Column()
            .setName('json')
            .setType(ColumnDataType.JSON)
        ]
    )

db.addTable(table)

db.once("ready", () => {
    const data = {
        id: '1',
        swords: 5
    }

    db.insert("users", data) // Insert the data into a row in the database.

    db.set("users", {
        json: {
            set: {
                bool: true
            }
        }
    }, {
        column: 'id',
        equals: '1'
    }) // Set json value

    console.log(
        db.get("users", '1')
    ) // Get data back
})

db.connect()

Package Sidebar

Install

npm i rhino.db

Weekly Downloads

1

Version

4.8.0

License

MIT

Unpacked Size

149 kB

Total Files

185

Last publish

Collaborators

  • ruben40000