Show More
Commit Commit message Age Author Refs
r4:54d7cb551e89
Created console messages to match @webb/ensure-table
0
r3:d75a1ca8cae3
Upgraded deps
0
r2:d19f0ae20c95
Updated deps and removed private registry
0
r1:5804627632fc
Updated README
0
r0:e829903e2ba1
Initial commit
0
< 1 >

@webb/ensure-database

Ensure your desired RethinkDB database exists.
If not, it gets created.

Install

# Install this module, with RethinkDB driver
$ npm i @webb/ensure-database rethinkdb-ts

Usage

import ensureDatabase from "@webb/ensure-database";
import server from "some-module";

const databaseOptions = {
  buffer: 2,
  db: "my-cool-product",
  discovery: false,
  host: "localhost",
  max: 5,
  password: "need-a-vc-to-sell-my-company-to-faang",
  port: 90210,
  silent: true,
  user: "admin"
};

server.listen(3000, async() => {
  try {
    await ensureDatabase({ name: "yourDatabase", options: databaseOptions });
  } catch(databaseError) {
    console.error(databaseError);
  }

  console.info("Server is running at port 3000");
});

API

ensureDatabase({ name, options? })

name

Type: string (required)

options

Type: object (optional)

Available options:

// All values are defaults, aside from "db".
// Internally, "db" will be the same value as "name" if not declared.
{
  buffer: 2,
  db: name,
  discovery: false,
  host: "localhost",
  max: 5,
  password: "",
  port: 28015,
  silent: true,
  user: "admin"
}

Tests

# Run all tests, sequentially
$ npm test

# Test dependencies for latest versions
$ npm run test:dependencies

# Lint "src" directory
$ npm run test:typescript

# Test this module
$ npm run test:assert