All Projects → eveningkid → Denodb

eveningkid / Denodb

Licence: mit
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Denodb

Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+677.91%)
Mutual labels:  orm, database, mysql, mongodb, postgresql, sqlite, sqlite3
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+3548.19%)
Mutual labels:  orm, database, mysql, postgresql, mariadb, mongo, sqlite
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-64.66%)
Mutual labels:  orm, mysql, mongodb, postgresql, sqlite, mariadb
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+515.06%)
Mutual labels:  orm, database, mysql, mongodb, postgresql, sqlite
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+468.67%)
Mutual labels:  orm, database, mysql, mongodb, postgresql, sqlite
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+5233.13%)
Mutual labels:  orm, database, mysql, postgresql, sqlite, mariadb
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+343.98%)
Mutual labels:  orm, database, mysql, postgresql, sqlite, mariadb
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+5004.82%)
Mutual labels:  orm, mysql, postgresql, sqlite, mariadb
Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+1155.42%)
Mutual labels:  orm, database, mysql, postgresql, sqlite
Phpmyfaq
phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases
Stars: ✭ 494 (-0.8%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb
Ebean
Ebean ORM
Stars: ✭ 1,172 (+135.34%)
Mutual labels:  orm, database, mysql, sqlite, mariadb
Doctrinejsonfunctions
Doctrine DQL functions for SQL JSON data type
Stars: ✭ 325 (-34.74%)
Mutual labels:  orm, mysql, postgresql, sqlite, mariadb
Qb
The database toolkit for go
Stars: ✭ 524 (+5.22%)
Mutual labels:  orm, database, mysql, postgresql, sqlite3
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-89.76%)
Mutual labels:  orm, database, mysql, postgresql, sqlite
Evolve
Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
Stars: ✭ 477 (-4.22%)
Mutual labels:  database, mysql, postgresql, sqlite, mariadb
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+8.23%)
Mutual labels:  orm, database, mysql, postgresql, sqlite
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-63.65%)
Mutual labels:  orm, database, mysql, postgresql, sqlite
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+364.86%)
Mutual labels:  database, mysql, mongodb, sqlite, mariadb
Endb
Key-value storage for multiple databases. Supports MongoDB, MySQL, Postgres, Redis, and SQLite.
Stars: ✭ 208 (-58.23%)
Mutual labels:  database, mysql, mongodb, postgresql, sqlite
Walkable
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Stars: ✭ 384 (-22.89%)
Mutual labels:  orm, mysql, postgresql, sqlite, sqlite3

DenoDB

  • 🗣Supports PostgreSQL, MySQL, MariaDB, SQLite and MongoDB
  • 🔥Simple, typed API
  • 🦕Deno-ready
  • Read the documentation
import { DataTypes, Database, Model, PostgresConnector } from 'https://deno.land/x/denodb/mod.ts';

const connection = new PostgresConnector({
  host: '...',
  username: 'user',
  password: 'password',
  database: 'airlines',
});

const db = new Database(connection);

class Flight extends Model {
  static table = 'flights';
  static timestamps = true;

  static fields = {
    id: { primaryKey: true, autoIncrement: true },
    departure: DataTypes.STRING,
    destination: DataTypes.STRING,
    flightDuration: DataTypes.FLOAT,
  };

  static defaults = {
    flightDuration: 2.5,
  };
}

db.link([Flight]);

await db.sync({ drop: true });

await Flight.create({
  departure: 'Paris',
  destination: 'Tokyo',
});

// or

const flight = new Flight();
flight.departure = 'London';
flight.destination = 'San Francisco';
await flight.save();

await Flight.select('destination').all();
// [ { destination: "Tokyo" }, { destination: "San Francisco" } ]

await Flight.where('destination', 'Tokyo').delete();

const sfFlight = await Flight.select('destination').find(2);
// { destination: "San Francisco" }

await Flight.count();
// 1

await Flight.select('id', 'destination').orderBy('id').get();
// [ { id: "2", destination: "San Francisco" } ]

await sfFlight.delete();

await db.close();

First steps

Setting up your database with DenoDB is a four-step process:

  • Create a database, using Database (learn more about clients):

    const connection = new PostgresConnector({
      host: '...',
      username: 'user',
      password: 'password',
      database: 'airlines',
    });
    
    const db = new Database(connection);
    
  • Create models, extending Model. table and fields are both required static attributes:

    class User extends Model {
      static table = 'users';
    
      static timestamps = true;
    
      static fields = {
        id: {
          primaryKey: true,
          autoIncrement: true,
        },
        name: DataTypes.STRING,
        email: {
          type: DataTypes.STRING,
          unique: true,
          allowNull: false,
          length: 50,
        },
      };
    }
    
  • Link your models, to add them to your database instance:

    db.link([User]);
    
  • Optional: Create tables in your database, by using sync(...):

    await db.sync();
    
  • Query your models!

    await User.create({ name: 'Amelia' });
    await User.all();
    await User.deleteById('1');
    

Migrate from previous versions

License

MIT License — eveningkid

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].