Skip to content

daniel-onyenwee/postgres-mini

Repository files navigation

postgres-mini

A package to run an mini postgres database right from NodeJS.

Install

npm i postgres-mini

Usage

import Postgres from 'postgres-mini'

async function main() {
    // Create a postgres instance.
    const pgInstance = await Postgres.create()

    // Initialize the postgres instance and set all configuration  
    await pgInstance.initialize()

    // Start the postgres instances
    await pgInstance.start()

    // Create a database
    await pgInstance.createDatabase("PERSON")

    // Make a query
    const result = await pgInstance.query("SELECT datname FROM pg_database")

    // Stop the postgres instances
    await pgInstance.stop()
}

main()

Documentation

Link

Credits

Postgres mini was created based on the inspiration of Lei Nelissen embedded-postgres package.