GithubHelp home page GithubHelp logo

meteor-rethinkdb's Introduction

#RethinkDB integration for Meteor

meteor add simple:rethink

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 a server to respond)
  • User accounts stored in RethinkDB and not in MongoDB (in plans)

##Using the Package

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

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 it on localhost:28015.

###Tables

Declare a table connected to the database on the server and a client-side cache on the client, (be sure that you have created the table in your database before-hand):

Players = Rethink.Table('players');

You can query the data using ReQL:

console.log('Number of players:', Players.count().run());
console.log('All players:', Players.run().toArray());

There is a shortcut for fetching the documents without turning a cursor into an array:

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

For constructing more complex queries, you can use the Rethink.r namespace.

var r = Rethink.r;

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

##Package Development

Since the package relies on 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

meteor-rethinkdb's People

Contributors

slava avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.