Postgres ORM Thing

Easier Node Postgres

Paul Dirac was a theoretical physicist who made fundamental contributions to the early development of both quantum mechanics and quantum electrodynamics.

Dirac.js is an extendable and configurable database layer built on top of MoSQL and made for Node Postgres. It has a pluginable architecture and ships with sensible middleware so you can avoid repetitive tasks.

Getting Started

Dirac.js is meant to be a solid starting point for your main database module. While you could have all of your logic in a single file, I like to group code by table as seen in the file structure below:

dirac.raw

dirac.register( callback )

Registers a new table or view with dirac. Will not actually create the table until dirac.sync() is called. Alternatively, you could call: dirac.dals.table.createIfNotExists() to manually add it. However, sync will resolve table dependencies and it will also save the database state so dirac can reason about your current table structure.

dirac.saveCurrentDbState( version, [callback] )

Save an entry in the dirac_schemas table of the current DAL state in memory. This happens everytime you call `sync`

Arguments

@param {Object} options - Options for sync

@property {Boolean} force - If `true` will perform destructive sync

@param {Function} callback( error )

Table Documentation

dirac.dals.table.find( $query, [options], [callback] )

Select documents in `table_name`. The `$query` object is the `where` property of a MoSQL object. The `options` object is mixed into the main query object sent to dirac.dals.table.query and makes up the rest of the query.