GitHub - blakevanlan/rethinkdb-setup: Quickly sets up RethinkDB for testing | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

blakevanlan/rethinkdb-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RethinkDB Setup

Quickly sets up RethinkDB for testing.

Codeship Status for blakevanlan/rethinkdb-setup

Install

npm install rethinkdb-setup

Usage

Connect to a RethinkDB and set up tables.

var RethinkdbSetup = require('rethinkdb-setup')

var config = {
   connection: {
      // Connection config, passed straight to r.connect.
      db: "test" // sets the default db
      host: "localhost" // sets the host
   },
   tables: {
      // Creates 'table0' with normal primary key.
      table0: true, 
      // Creates 'table1' with normal primary key.
      table1: "id", 
      // Creates 'table2' with 'primaryKey' as the primary key.
      table2: "primaryKey", 
      // Creates 'table3' with 'primaryKey' as the primary key and adds a
      // seconardy index on email.
      table3: ["primaryKey", "email"],
      // Creates 'table4' with normal primary key and adds a geo index to 'location'.
      table4: ["id", {name: "location", indexFunction: null, options: {geo: true}}],
      // Creates 'table5' with normal primary key and adds an index with an arbitrary
      // ReQL expression.
      table5: [
         "id", 
         {
            name: "fullname",
            indexFunction: function(user) {
               return r.add(user("last_name"), "_", user("first_name"));
            })
         }
      ]
   }
};

// NOTE: The rethinkdb module checks the validity of the connection using
// a instanceof meaning that the module can throw an error if two different
// versions are being used with the same connection.
RethinkdbSetup.connectAndSetup(config, function (err, connection) {
   //...
});

// If you already have a connnection, just pass it to setup directly.
RethinkdbSetup.setup(connection, config, function (err) {
   //...
});

Later on, you can then empty the tables.

RethinkdbSetup.empty(connection, config, function (err) {
   //...
});

You can also insert data into tables.

data = {
   table0: [{id: '123', foo: 'bar'}, {id: '456', foo: 'apples'}]
};
RethinkdbSetup.load(rethinkdbConnection, data, function (err) {
   //...   
});

About

Quickly sets up RethinkDB for testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.