Skip to content
Robert Gaggl edited this page Nov 1, 2010 · 8 revisions

Basics

Setting up Ringo SQLstore basically requires requiring the module and creating a new Store instance, passing the database connection parameters:

var Store = require("ringo/storage/sql/store").Store;
var store = new Store({
    "url": "jdbc:h2:mem:test",
    "driver": "org.h2.Driver"
});

The above example would operate on a H2 in-memory database within the JVM, which is created when the first connection to the database is opened. An example for a PostgreSQL database would look like this:

var store = new Store({
    "url": "jdbc:postgresql://192.168.1.1/test",
    "driver": "org.postgresql.Driver",
    "username": "test",
    "password": "test"
});

Depending on the database driver you can add additional properties to the object passed as argument to the Store constructor. Within one application you can instantiate as many stores as needed, each operating on it's own database.

Once the store is set up correctly, you should continue defining entities managed by this store instance.

Clone this wiki locally