Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 1.93 KB

getting-started.md

File metadata and controls

61 lines (42 loc) · 1.93 KB

Getting Started with ORMnomnom

ORMnomnom is a lightweight ORM; its goal is to make the code you write around 80% of your business logic fast and flexible, and then get out of your way for the remaining 20%.

The first step in getting started with ORMnomnom is to determine whether or not it will fit your needs.

In particular, ORMnomnom:

  • Exposes a Promise-based API.
  • Requires Node v4+.
  • Is only tested with Postgres.
  • Does not provide a solution for aggregates or self-referencing queries.
  • Does not handle database migrations.

If these things sound okay to you, or you don't know what these things mean but this sounds fun anyway, read on!

Prerequisites

You'll need Node v4 or greater and a database, we recommend Postgres. For help on getting those, check out this doc.

Installing ORMnomnom in Your Project

In your shell, navigate to your project. In your project directory, run the following command:

$ npm install ormnomnom pg

This will install ormnomnom and the pg client and record the dependencies in your project's package.json, if it exists.

Note: For npm version 4 and below, you need to pass --save to the install command to add the installed dependencies to your package.json.

If you get any errors from this process, please open an issue.

Setting up a Connection

ORMnomnom does not know how to get a postgres connection out of the box — your application is in charge of telling ORMnomnom how to attain a connection. ORMnomnom will try to attain a connection whenever a query is about to be run, and will release that connection after the query has executed.

An example of creating a connection follows:

const orm = require('ormnomnom')
const pg = require('pg')

orm.setConnection(() => pg.connect())

The next step is to start defining models!