iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower
Apache License 2.0
393 stars 82 forks source link

Now way to get the whole doc #41

Open LeHibou opened 10 years ago

LeHibou commented 10 years ago

Hello,

I tried the following code :


var app = require('express')(), server = require('http').createServer(app), io = require('socket.io').listen(server);

server.listen(8888);

var follow = require('follow'); follow({db:"http://localhost:5984/baseball/", include_docs:true}, function(error, change) { if(!error) { console.log("Got change number " + change.seq + ": "); io.sockets.on('connection', function (socket) {

    socket.emit('news', change);

}); } })


My doc is of the form :

{ "_id": "3a926675dbac89820e2f8b3746001003", "_rev": "28-57309ea14f606e494dc94cd0816f8d99", "re": "hgypmp", "mim": "ghj" }

How can I pass the value of re and mim to the browser ? I saw that I can grab the key but no way I can get change.re or change.mim.

Any idea ?

Thanks !

LeHibou commented 10 years ago

Solved :

I had to iterate over change.doc in a loop and extract the part[i].

Many thanks !

LeHibou