All Projects → citycide → Trilogy

citycide / Trilogy

Licence: mit
TypeScript SQLite layer with support for both native C++ & pure JavaScript drivers.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Trilogy

Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+3854.87%)
Mutual labels:  hacktoberfest, sql, database, sqlite
Node Sqlite
SQLite client for Node.js applications with SQL-based migrations API written in Typescript
Stars: ✭ 642 (+229.23%)
Mutual labels:  async, sql, database, sqlite
Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (+67.18%)
Mutual labels:  sql, database, sqlite, model
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+983.08%)
Mutual labels:  schema, sql, database, sqlite
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-73.33%)
Mutual labels:  hacktoberfest, database, sqlite
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+4590.77%)
Mutual labels:  sql, database, sqlite
Sql.js
A javascript library to run SQLite on the web.
Stars: ✭ 9,594 (+4820%)
Mutual labels:  sql, database, sqlite
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+549.74%)
Mutual labels:  sql, database, sqlite
Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (-91.28%)
Mutual labels:  schema, database, model
Ebean
Ebean ORM
Stars: ✭ 1,172 (+501.03%)
Mutual labels:  sql, database, sqlite
Ocaml Caqti
Cooperative-threaded access to relational data
Stars: ✭ 175 (-10.26%)
Mutual labels:  async, database, sqlite
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-7.18%)
Mutual labels:  sql, database, sqlite
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+404.62%)
Mutual labels:  sql, database, sqlite
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-70.77%)
Mutual labels:  schema, sql, database
Avsqldebugger
A Simple Core Data Debugger that will look inside your apps DB
Stars: ✭ 30 (-84.62%)
Mutual labels:  sql, database, sqlite
Vue Rawmodel
RawModel.js plugin for Vue.js v2. Form validation has never been easier!
Stars: ✭ 79 (-59.49%)
Mutual labels:  promise, schema, model
Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (-46.67%)
Mutual labels:  schema, sql, database
Datastore
🐹 Bloat free and flexible interface for data store and database access.
Stars: ✭ 99 (-49.23%)
Mutual labels:  async, database, model
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-34.87%)
Mutual labels:  sql, database, sqlite
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (+293.33%)
Mutual labels:  schema, sql, database

trilogy
Version License Travis CI Written in TypeScript JavaScript Standard Style Gitter

trilogy is a simple Promise-based wrapper for SQLite databases. It supports both the native C++ sqlite3 driver and the pure JavaScript sql.js backend — compile natively for speed when you need it, or use sql.js headache-free in cross-platform environments and Electron apps.

It's not an ORM and isn't intended to be one — it doesn't have any relationship features. Instead it focuses on providing a simple, clear API that's influenced more by Mongoose than by SQL.


features · installation · usage · contributing · license


features

  • 🔗 automatically casts data between JavaScript & SQLite types

    Define schemas with types like String, Date, or 'increments' — trilogy will handle all the type-casting involved to map accurately between JavaScript and the underlying SQLite database.

  • 🔋 powered by the knex query builder

    trilogy uses knex internally to build its queries, but it's also exposed so you can use it to build your own. No need to mess with ridiculous multi-line strings.

  • 🔩 supports multiple swappable backends ( plus in-memory storage )

    Both the native sqlite3 module and sql.js (pure JavaScript!) are supported. There is also memory-only storage for fast, unpersisted data handling, which is great for tests and performance critical situations.

    You can even swap the backend after you've started, with no changes to the rest of your code!

  • 👮 written in TypeScript

    trilogy is written in and provides a first-class experience for TypeScript.

  • 🔌 lifecycle hooks

    Any number of hooks (aka subscribers or listeners) can be attached at several points in the lifecycle — for example onQuery, beforeCreate, afterUpdate. These are useful for debugging and extensibility.

  • 💞 perfect for Electron & NW.js

    Compiling the sqlite3 module for all the platforms you target with Electron or NW.js can be difficult. That's why trilogy also supports the sql.js backend, which doesn't need to be compiled at all!

installation

  1. Install trilogy

    # using yarn
    yarn add trilogy
    
    # using npm
    npm i trilogy
    
  2. Install a backend

    # using yarn
    yarn add sqlite3
    
    # using npm
    npm i sqlite3
    

    or

    # using yarn
    yarn add sql.js
    
    # using npm
    npm i sql.js
    

usage

Full documentation is available here and includes guides, an API reference, and more.

Here's a quick overview. It uses async & await but is easily usable with vanilla Promises.

import { connect } from 'trilogy'

// defaults to using the `sqlite3` backend
const db = connect('./file.db')

// choose `sql.js` to avoid native compilation :)
const db = connect('./file.db', {
  client: 'sql.js'
})

// set the filename to ':memory:' for fast, in-memory storage
const db = connect(':memory:', {
  // it works for both clients above!
  client: 'sql.js'
})

;(async function () {
  const games = await db.model('games', {
    name: { type: String },
    genre: String,            // type shorthand
    released: Date,
    awards: Array,
    id: 'increments'          // special type, primary key
  })

  await games.create({
    name: 'Overwatch',
    genre: 'FPS',
    released: new Date('May 23, 2016'),
    awards: [
      'Game of the Year',
      'Best Multiplayer Game',
      'Best ESports Game'
    ]
  })

  const overwatch = await games.findOne({ name: 'Overwatch' })

  console.log(overwatch.awards[1])
  // -> 'Best Multiplayer Game'
})()

contributing

This project is open to contributions of all kinds! Don't worry if you're not 100% up to speed on the process — there's a short outline in the Contributor Guide.

You'll also find a reference for the set of labels used to categorize issues, with descriptions of each. (Contributor Guide - issue labels)

Also, please read and follow the project's Code of Conduct.

license

MIT © Bo Lingen / citycide

See license

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].