iriscouch / follow

Very stable, very reliable, NodeJS CouchDB _changes follower

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changes and rewites

abarysiuk opened this issue · comments

I found that feed.db = 'http://myvhost.com/alias_db' won't work, where:
myvhost.com = real_host/real_db/_design/app/_rewrite/

rewrite
{
"from": "/alias_db/",
"to": "../../*"
}

It simply hangs and print nothing. I'm able to get result via feed.db = real_host/real_db. Also i'm able to get changes set via 'curl http://myvhost.com/alias_db/_changes'.

Very interesting. I think Follow will try to confirm the database first, so perhaps it is failing there. Do you have any 4xx or 5xx messages in your server log?

Good point about the logs! I think i found the problem. So rewrite

{
    "from": "/alias_db/",
    "to": "../../*"
}

cause 'curl http://myvhost.com/alias_db' return information about real db, like:

{"db_name":"real_db"  ...

But 'curl http://myvhost.com/alias_db/_changes' doesn't work - rewire is translated into /real_db/_design/app/alias_db/_changes = 404

Changing rewrite to:

{
    "from": "/alias_db/*",  <- * symbol at the end
    "to": "../../*"
}

cause 'curl http://myvhost.com/alias_db' return:

{"error":"not_found","reason":"Document is missing attachment"}

and Follow throws error:

[Error: Bad DB response: {"error":"not_found","reason":"Document is missing attachment"}]

I don't know yet how to write such rewrite that will handle both cases well /