Skip to content

Instantly share code, notes, and snippets.

@elevine
Last active February 18, 2016 20:18
Show Gist options
  • Select an option

  • Save elevine/6393316cb6cf6ec786e8 to your computer and use it in GitHub Desktop.

Select an option

Save elevine/6393316cb6cf6ec786e8 to your computer and use it in GitHub Desktop.
Sync Gateway Websocket Consumer and Producer
var WebSocket = require('ws');
var ws = new WebSocket('ws://server-address-here:4984/db/_changes?feed=websocket');
ws.onopen = function() {
console.log("Open");
};
ws.onmessage = function(data, flags) {
console.log("on message");
};
var request = require('request');
var options = {
url : "http://server-address-here:4984/db/",
json: true
};
options.body = {
foo: "foo",
channels: ["test"]
};
request.post(options, function(err, msg, response){
console.log(response);
} );
{
"log": ["*"],
"databases": {
"db": {
"server": "http://localhost:8091",
"bucket": "sync_gateway",
"users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } },
"sync":`function(doc) {channel(doc.channels);}`
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment