Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incoming is not triggered when using pouchDB put function #36

Open
lamm opened this issue Nov 7, 2016 · 5 comments
Open

incoming is not triggered when using pouchDB put function #36

lamm opened this issue Nov 7, 2016 · 5 comments

Comments

@lamm
Copy link

lamm commented Nov 7, 2016

Hello,

I used transform-pouch (v1.1.3) within node.js (v6.7.0) to access a couchdb (v1.6.1) backend server. When i use PouchDB (v 6.0.5) post function, incoming is triggered. But, when i use PouchDB put function it is not.

Can you help ?
Thanks for your support.

Here is the code of my node app and the resulting console output :

Node app code

var express = require('express')
  , http = require('http')

var app = express();
app.set('port', process.env.PORT || 3000);

var PouchDB = require('pouchdb');
PouchDB.plugin(require('transform-pouch'));
var db = new PouchDB('http://localhost:5984/db');
db.transform({    
	outgoing: function(doc) {
		console.log("****Outgoing****" + ":" + JSON.stringify(doc));
		return doc;
	},
	incoming: function(doc) {
		console.log("****Incoming****" + ":" + JSON.stringify(doc));
		return doc;
	}
});

db.put({"_id": "test", "PUT":"PUT"}).then(function (result) {
	console.log("PUT result")
	console.log(result)
	db.get("test").then(function (result) {
		console.log("GET result");
		console.log(result);
		db.post({"test": "test", "POST":"POST"}).then(function (result) {
			console.log("POST result")
			console.log(result)
		})
	})
}).catch(function (err) {
	console.log(err);
});

var server = http.createServer(app).listen(app.get('port'), function(){
  console.log('Express server listening on port ' + app.get('port'));
});

Node output console

Express server listening on port 3000
PUT result
{ ok: true,
  id: 'test',
  rev: '7-92c1e5528c692fbeb6cf97f0687f53e7' }
****Outgoing****:{"_id":"test","_rev":"7-92c1e5528c692fbeb6cf97f0687f53e7","PUT":"PUT"}
GET result
{ _id: 'test',
  _rev: '7-92c1e5528c692fbeb6cf97f0687f53e7',
  PUT: 'PUT' }
****Incoming****:{"test":"test","POST":"POST"}
POST result
{ ok: true,
  id: 'bf6cf5681c3fb3207a5380f1ad004629',
  rev: '1-319fa1494afe5f62e191725989a66c34' }
@nolanlawson
Copy link
Member

Thanks for reporting. I will try to look at this when I get a chance but I admit I am swamped right now, so if you could debug on an unmagnified build of transform-pouch that may help narrow down the cause of the problem. :) Thanks!

On Nov 7, 2016, at 1:08 AM, lamm [email protected] wrote:

Hello,

I used transform-pouch (v1.1.3) within node.js (v6.7.0) to access a couchdb (v1.6.1) backend server. When i use PouchDB (v 6.0.5) post function, incoming is triggered. But, when i use PouchDB put function it is not.

Can you help ?
Thanks for your support.

Here is the code of my node app and the resulting console output :

Node app code*****
var express = require('express')
, http = require('http')

var app = express();
app.set('port', process.env.PORT || 3000);

var PouchDB = require('pouchdb');
PouchDB.plugin(require('transform-pouch'));
var db = new PouchDB('http://localhost:5984/db http://localhost:5984/db');
db.transform({
outgoing: function(doc) {
console.log("Outgoing" + ":" + JSON.stringify(doc));
return doc;
},
incoming: function(doc) {
console.log("Incoming" + ":" + JSON.stringify(doc));
return doc;
}
});

db.put({"_id": "test", "PUT":"PUT"}).then(function (result) {
console.log("PUT result")
console.log(result)
db.get("test").then(function (result) {
console.log("GET result");
console.log(result);
db.post({"test": "test", "POST":"POST"}).then(function (result) {
console.log("POST result")
console.log(result)
})
})
}).catch(function (err) {
console.log(err);
});

var server = http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});

Node output console
Express server listening on port 3000
PUT result
{ ok: true,
id: 'test',
rev: '7-92c1e5528c692fbeb6cf97f0687f53e7' }
Outgoing:{"_id":"test","_rev":"7-92c1e5528c692fbeb6cf97f0687f53e7","PUT":"PUT"}
GET result
{ _id: 'test',
_rev: '7-92c1e5528c692fbeb6cf97f0687f53e7',
PUT: 'PUT' }
Incoming:{"test":"test","POST":"POST"}
POST result
{ ok: true,
id: 'bf6cf5681c3fb3207a5380f1ad004629',
rev: '1-319fa1494afe5f62e191725989a66c34' }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub #36, or mute the thread https://github.com/notifications/unsubscribe-auth/AARUwmybcJnrULXXyOCzotYMAPSHXG39ks5q7up8gaJpZM4Kq-tO.

@lamm
Copy link
Author

lamm commented Nov 8, 2016

Hello,
Yes, i can do some debug if it can help, but when you say "debug on an unmagnified build of transform-pouch" ==> what do you mean ?
Thanks.

@nolanlawson
Copy link
Member

"unminified," sorry for the typo

@chisNaN
Copy link

chisNaN commented Apr 9, 2019

Hello, still it has not been solved?
thanks

@jcoglan
Copy link
Collaborator

jcoglan commented Aug 4, 2021

Hi folks, this issue with incoming() not running on put() to remote databases has been noticed by a few people and we believe it is fixed in master and the newly released v2.0.0. Would you be able to check whether this issue is now resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants