Skip to content

About

GJS - Active Record (Postgres/MySQL/SQLite)

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

GJS ActiveRecord

A lightweight, asynchronous ActiveRecord ORM designed for GJS (GNOME JavaScript) applications. Built natively on top of libgda (GNOME Data Access).

Features

  • Native GJS Integration: Uses standard GObject Introspection (imports.gi.Gda).
  • Asynchronous API: All database operations return Promises to prevent blocking the UI thread.
  • Vendoring Ready: Distributed as standard ES Modules. Just drop the folder into your project's source.
  • Multiple Adapters: Designed to be extensible. Currently supports PostgreSQL out-of-the-box.

Usage

Simply drop the ActiveRecord directory into your project.

import { ActiveRecord } from './ActiveRecord.js';

class User extends ActiveRecord {
    static tableName = 'users';

    constructor(data) {
        super(data);
    }
}

async function main() {
    // 1. Connect
    await ActiveRecord.connect('DB_NAME=my_db;HOST=localhost', 'USERNAME=postgres;PASSWORD=secret');

    // 2. Query
    let user = await User.find(42);
    
    // 3. Mutate and save
    if (user) {
        user.name = "Michael";
        await user.save(); 
    }
}
main();

Requirements

  • GJS
  • libgda-5.0 (or compatible version) and the corresponding provider (e.g., libgda-5.0-postgres).

Running the Example

To run the example test script natively:

gjs -m example.js

About

GJS - Active Record (Postgres/MySQL/SQLite)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages