Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/guidesmiths/marv-pg-driver

A postgres marv driver implementation
https://github.com/guidesmiths/marv-pg-driver

hacktoberfest

Last synced: 2 months ago
JSON representation

A postgres marv driver implementation

Awesome Lists containing this project

README

        

[![NPM version](https://img.shields.io/npm/v/marv-pg-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-pg-driver)
[![NPM downloads](https://img.shields.io/npm/dm/marv-pg-driver.svg?style=flat-square)](https://www.npmjs.com/package/marv-pg-driver)
[![Node.js CI](https://github.com/guidesmiths/marv-pg-driver/workflows/Node.js%20CI/badge.svg)](https://github.com/guidesmiths/marv-pg-driver/actions?query=workflow%3A%22Node.js+CI%22)
[![Maintainability](https://api.codeclimate.com/v1/badges/f4f00937958b3ad25af5/maintainability)](https://codeclimate.com/github/cressie176/marv-pg-driver/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f4f00937958b3ad25af5/test_coverage)](https://codeclimate.com/github/cressie176/marv-pg-driver/test_coverage)
[![Code Style](https://img.shields.io/badge/code%20style-prettier-brightgreen.svg)](https://github.com/prettier/prettier)

# marv-pg-driver

A postgres driver for [marv](https://www.npmjs.com/package/marv)

## Usage

```
migrations/
|- 001.create-table.sql
|- 002.create-another-table.sql
```

### Promises

```js
const marv = require('marv/api/promise'); // <-- Promise API
const driver = require('marv-pg-driver');
const directory = path.resolve('migrations');
const connection = {
// Properties are passed straight pg.Client
host: 'postgres.example.com',
};

const migrations = await marv.scan(directory);
await marv.migrate(migrations, driver({ connection }));
// Profit :)
```

### Callbacks

```js
const marv = require('marv/api/callback'); // <-- Callback API
const driver = require('marv-pg-driver');
const directory = path.resolve('migrations');
const connection = {
// Properties are passed straight pg.Client
host: 'postgres.example.com',
};

marv.scan(directory, (err, migrations) => {
if (err) throw err;
// Connection properties are passed straight pg.Client
marv.migrate(migrations, driver({ connection }), (err) => {
if (err) throw err;
// Profit :)
});
});
```

## Testing

```bash
npm install
npm run docker
npm test
```