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

https://github.com/ozum/pg-knex-seeder

Generate Knex seed files from a PostgreSQL database
https://github.com/ozum/pg-knex-seeder

Last synced: about 2 months ago
JSON representation

Generate Knex seed files from a PostgreSQL database

Awesome Lists containing this project

README

        

# pg-knex-seeder

Generates [Knex seed files](https://knexjs.org/#Seeds-CLI) from a PostgreSQL database using all or selected tables.

[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

# Synopsis

## CLI

```
$ npx pg-knex-seeder --out-dir seeds
$ npx pg-knex-seeder --out-dir seeds --env-name PG_CONNECTION_STRING --tables member,public.products --increment 5
```

## API

```js
import generateSeed from "pg-knex-seeder"

generateSeed({ outDir: `${__dirname}/seeds` })
.then(() => console.log("Seeds are generated..."))
.catch(e => console.error(e));

// with some parameters

generateSeed({
envName: "PG_CONNECTION_STRING", // Or use `connection` parameter
outDir: process.cwd(),
tables: ["other_schema.member", "member", "product"],
increment: 5,
schemaInFilename: true,
})
.then(() => console.log("Seeds are generated..."))
.catch(e => console.error(e));
```

# API
{{>main~}}