Skip to content

Manipulating the database

quenenni edited this page Apr 1, 2013 · 2 revisions

Some exemples on how to manipulate the Db

Instantiate the Db API:

var db = require('ep_etherpad-lite/node/db/DB').db

Get data from the Db:

db.get("record_key", function(err, record_value){

    // do something

});

Set data in the Db:

// Replace data value if the record already exists or create a new record with this key

db.set("record_key", data);

// Add a subvalue to an existing record data

db.setSub("record_key", ["sub_key"], value);

db.setsub example:

{"colorId":"#79d9d9","name":"tutti","timestamp":1364832712430,"padIDs":{"mypad":1}}

db.setSub("record_key", ["email"], "[email protected]");

{"colorId":"#79d9d9","name":"tutti","timestamp":1364832712430,"padIDs":{"mypad":1},"email":"[email protected]"}

Options

Db caching:

By default, the results from a db.get are cached (set initially to 1000).
In some case, it's not what you want.
To remove the caching system for requests, you can set the 'caching' option to 0

db['dbSettings'].cache = 0;

General

Resources

For Developers

How to's

Set up

Advanced steps

Integrating Etherpad in your web app

for Developers

Clone this wiki locally