Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/guidesmiths/marv-pg-driver
- Owner: guidesmiths
- License: isc
- Created: 2016-08-24T10:48:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T23:15:11.000Z (7 months ago)
- Last Synced: 2024-11-02T20:41:58.235Z (2 months ago)
- Topics: hacktoberfest
- Language: JavaScript
- Size: 341 KB
- Stars: 1
- Watchers: 14
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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
```