• Stars
    star
    302
  • Rank 137,239 (Top 3 %)
  • Language
    JavaScript
  • Created over 9 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RethinkDB integration for Meteor

RethinkDB integration for Meteor

A full-stack RethinkDB integration with Meteor. With livequery, publish/subscribe, latency compensation and client-side cache.

Work in progress. Not ready for its prime-time.

Intro

meteor add simple:rethink

Demo app: https://github.com/Slava/meteor-rethinkdb-demo

This packages aims to provide a first-class experience working with RethinkDB building full-stack real-time web and mobile apps on the Meteor framework.

The goals and plans of this package:

  • Raw access to RethinkDB on the server, no ORMs
  • Client-side cache accessible with the RethinkDB query language (ReQL)
  • Use Meteor's publications/subscriptions model
  • Take advantage of Meteor's "Latency Compensation" propeties (optimistic client-side updates without waiting for the server to respond)
  • User accounts stored in RethinkDB instead of MongoDB (planned)
  1. Using the package
  2. Setup
  3. Tables
  4. Queries
  5. Publishing
  6. Package development
  7. Contributions

Using the package

Setup

Adding a package is as simple as running the following command in your Meteor app's directory:

meteor add simple:rethink

The package will connect to a RethinkDB instance by looking at the RETHINK_URL environment variable.

env RETHINK_URL=rethinkdb://user:password@hostname:port/database meteor run

If you have an instance of RethinkDB running locally on your development computer, the package will automatically connect to the test db on localhost:28015.

To install and run RethinkDB on a Mac:

$ brew update
$ brew install rethinkdb
$ rethinkdb

Or install on another OS.

Tables

When using new Mongo.Collection('items'), the collection is automatically created in MongoDB if it does not exist. With RethinkDB, you must create the table yourself beforehand. You can do so in the web UI:

http://localhost:8080/#tables

Then declare the table:

Players = new Rethink.Table('players');

Queries

Query the data using the Javascript API for ReQL:

console.log('Number of players:', Players.count().run());
console.log('All players:', Players.run().toArray());
console.log('Updating players:', Players.filter({team: 'Knicks'}).update({city: 'NYC'}).run());

.fetch() is a shortcut for .run().toArray(), fetching the documents without turning the cursor into an array:

console.log('All players:', Players.fetch());

Construct more complex queries with Rethink.r:

var r = Rethink.r;

// Top Players
Players.orderBy(r.desc('score')).limit(3).fetch();

Publishing

Currently, observations (the type of queries you return from publish functions) can only be point queries (.get(primaryKey)) or orderBy & limit queries (.orderBy({ index: 'id' }).limit(4)).

Package development

Since the package relies on the RethinkDB node driver and Reqlite to build the package, make sure npm is available and ready for use. Then run the build script:

./driver-source/build.sh

This script will output a built version of Reqlite and driver for the client-side cache.

Running tests

Build the package first, then run the tests.

./driver-source/build.sh
meteor test-packages --driver-package respondly:test-reporter

Contributions

Currently this project is welcoming contributions to Reqlite, the mini-implementation of RethinkDB in browser that this package is using on the client-side for DB operations simulations. Also, this project would appreciate more tests testing out different commands.

More Repositories

1

label-tool

Web application for image labeling and segmentation
JavaScript
343
star
2

tern-meteor

Autocompletion plugin for Meteor 1.0 (extending TernJS)
JavaScript
284
star
3

tern-meteor-sublime

Meteor Framework autocompletion for Sublime
Python
246
star
4

vimrc

Meteor/Web development centric vim config
Vim Script
83
star
5

meteor-gmail

Real-time driver for GMail.
JavaScript
55
star
6

6.033-systems-engineering

notes from 6.033: watching lectures on OCW, doing assignments, reading papers, etc
44
star
7

diff.js

diff algorithm implemented in JavaScript
JavaScript
39
star
8

meteor-rethinkdb-demo

an example app
JavaScript
16
star
9

blaze-tools

lol wut
JavaScript
15
star
10

talk-player

JavaScript
13
star
11

d3-meteor-basic

an example
JavaScript
11
star
12

meteor-gmail-query-parser

GMail query syntax parser
JavaScript
11
star
13

typescript-types-script

for the lolz compiler to perform arbitrary computation in TS type system
Haskell
9
star
14

zbt-website

The new website for MIT ZBT
JavaScript
9
star
15

competitiveProgramming

Sources I generated over 4 years of competitive programming 2008-2012
C++
8
star
16

.spacemacs

My spacemacs file
Emacs Lisp
7
star
17

meteor-tracker-profiler

JavaScript
6
star
18

zbt-genealogy

JavaScript
6
star
19

meteor-mobile-icons-example

This example shows how to use icons and images with the new Meteor Mobile support
JavaScript
6
star
20

VKImage

Custom drawings for NSImage
Objective-C
4
star
21

emacs.d

Outdated, please refer to my spacemacs config
Emacs Lisp
4
star
22

reactive-array

Tracker-aware array implementation (WIP)
JavaScript
4
star
23

sqrt-skip-list-js

Doubly-linked list with insert/remove/random access/search optimization. NOT Skip List.
JavaScript
3
star
24

url-shortener

Url shortener for private use in small groups (teaching a class, etc).
JavaScript
3
star
25

meteor-ddp-analyzer

JavaScript
3
star
26

netflix-ko-vocab

A Chrome Extension that extends Netflix For Language Learners, showing better translations (and roots) for Korean subs
JavaScript
3
star
27

terminal-blog

Experimental meteor app
CSS
2
star
28

peliblog

Blog with Pelican
HTML
2
star
29

meteor-mongo-append-only

JavaScript
1
star
30

meteor-dashed-template-bug-repruduction

1
star
31

meteor-svg-barchart-example

JavaScript
1
star
32

topcoder

All my topcoder accepted solutions.
C++
1
star
33

malloc

One of the projects for the performance eng class, custom malloc with predictive bucket sizing, includes a visualizer in HTML/JS. We got an A for the class.
Python
1
star
34

pennapps-demo

Little application live-coded in 30 mins talk with introduction to Meteor.
CSS
1
star
35

slava.github.io

Future landing page
HTML
1
star
36

minilisp

For learning purposes. Don't laugh at me, I am learning!
C
1
star
37

org-asana

meh
JavaScript
1
star
38

desktop-email-server

JavaScript
1
star
39

klyrics

Klyrics - KPop music player with lyrics
JavaScript
1
star