npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adbm-rethinkdb

v1.1.1

Published

RethinkDB adapter for adbm database migration tool

Downloads

14

Readme

adbm-rethinkdb

js-standard-style

RethinkDB adapter for adbm database migration tool.

Installation

npm install adbm-rethinkdb

Helpers

This adapter contains a series of helper functions meant to simplify a few common migration tasks. These helper functions have been taken from the now deprecated reconsider module, as has their documentation. Each of these functions will return a database migration object, i.e. an object exposing up and down methods, which can then be exported by the migration file.

createTablesMigration

This function will return a migration that will create tables when migrating up and drop these tables when migrating down. createTablesMigration expects an array of table names.

// In file migrations/xx-create-tables.js
const helpers = require('adbm-rethinkdb/helpers')

module.exports = helpers.createTablesMigration([ 'first_table', 'second_table' ])

createIndexMigration

This function will return a migration that will create indices when migrating up and drop these indices when migrating down. createIndexMigration expects an array of index specifications. Each index specification is an object containing a table and an index property, and optionally an options object and/or a spec function. An options object can be anything that r.indexCreate() accepts, while the spec property must be a function that returns an index definition (which, again, can be anything that r.indexCreate() accepts). spec will be passed the rethinkdbdash instance when it is executed.

// In file migrations/xx-create-indices.js
const helpers = require('adbm-rethinkdb/helpers')
const table = 'first_table'

module.exports = helpers.createIndexMigration([
  { table, index: 'someProp' }, // Simple index
  { table, index: 'compoundIndex', spec: (r) => [ r.row('firstProp'), r.row('secondProp') ] }, // Compound index
  { table, index: 'geoProp', options: { geo: true } }, // Geo index
  { table, index: 'multiIndex', options: { multi: true } }, // Multi index
  { table, index: 'arbitraryExpr', spec: (r) => (doc) => r.branch(doc.hasFields('foo'), doc('foo'), doc('bar')) } // Index based on an arbitrary expression
])

Testing

Running tests requires a rethinkdb database. You can either point the tests to your own rethinkdb server using environment variables (see below) or use the included docker:db npm script to spin up a docker container called adbm_rethinkdb_dev_db that will provide you with a basic rethinkdb server. After that, you'll simply want to:

npm run test

Environment Variables

const dbConfig = {
  host: process.env.DB_HOST || 'localhost',
  port: process.env.DB_PORT,
  authKey: process.env.DB_AUTH_KEY,
  db: process.env.DB_NAME || 'adbm_rethinkdb'
}

I.e. when supplying no configuration, tests will attempt to connect to localhost on the default port and will attempt to use the adbm_rethinkdb database (which will be created if it does not already exist).

Author

Michael Smesnik at tailored apps

License

MIT