I'm trying to sync a database in a local CouchDB installation (v 1.3.1 on a Mac) and a database on Cloudant with master-master replication.
In my local Futon http://localhost:5984/_utils I've configured Replicator to replicate my local database to Cloudant. Everything works fine replicating from the local database to the Cloudant one, but not backwards. If data changes in the Cloudant's database those changes are not been replicated to my local database.
Local -> Cloudant = works
Cloudant -> Local = doesn't work
Is this possible to be made? Can anyone help?
Thanks!
Finally I figured out that I only needed to configure two replications from my local CouchDB.
Here are both replications:
{
"source":"https://username:pwd#username.cloudant.com/cloud_db",
"target":"http://username:pwd#localhost:5985/local_db"
}
{
"source":"http://username:pwd#localhost:5985/local_db",
"target":"https://username:pwd#username.cloudant.com/cloud_db"
}
Now, in http://localhost:5984/_utils/status.html there are two replications running.
Note that I added the username and password to the local connection too. That's because you need to be an authorized user in order to replicate design documents.
Thanks a lot Mike, your answer helped a lot!
Can you try specifying full URLs for both source and target? I think it would look like:
#create the replicator database for your local server
curl -X PUT 'http://127.0.0.1:5984/_replicator'
then upload this document:
{
"source":"https://username:pwd#username.cloudant.com/source_db",
"target":"http://127.0.0.1:5985/target_db"
}
Then you should be able to monitor that by a:
http://127.0.0.1:5984/_active_tasks
If that doesn't work for you, can you please copy/paste:
the body of the document in the _replicator database
grep the log file for anything with _replication
Also, there's a classic 'gotcha' here, that I think you need 'writer' permissions on both the source and target database. That may seem odd, but it's because the replicator is saving checkpoint documents on both the source and the target so that the next time you ask to replicate, it doesn't have to start from scratch.
Related
i followed a tutorial and made a todo list web app using nodejs, express and ejs. after completing i used ngrok to make my localhost public so that i can share it with my friends, now i've realized that the tasks that i add on my todo list are saved in my server unless i restart it or close it completely. i want to know where the tasks which is a is stored in my local machine, does nodejs store it, or its saved in the memory of my local machine, more importantly if its already being stored somewhere why do i have to worry about using a database server like mongodb or firebase? hope my question is clear.
If you store your data in array or something in your code i can say "Yes. the data would be stored in the memory of your local machine".
And you don't have to worry about database if you don't have to permanently store your data.
I am working with NodeJS and Cloudant (alternatively the DashDB Warehouse if that works better). I wonder if it is possible to have a function in NodeJS that gets called each time a document has been added to the database? I have checked out indexed views but can't really understand how to do it. Does anyone have any good tips regarding this or what documentation to look at?
You can listen to DB _changes in Cloudant (https://console.bluemix.net/docs/services/Cloudant/api/database.html) in continous mode.
Every document change in the Cloudant DB (create,update,delete) will be notified through this channel.
There are different nodejs libraries you can use with this purpose. This is
one example: https://www.npmjs.com/package/cloudant-follow
I have an nodejs server running witch show data on a web interface. The data is fetched from a MongoDB using mongoose. The data is added via an node-red application witch is isolated from the rest.
Currently my nodejs server fetches the data every 5 seconds. Is there a way to know if the data in my MongoDB has changed?
Thanks, I hope my question is clear.
I was also looking for something similar to what you are asking for few months back. Few ways which i know to do it are:
1) You can try to use middlewares while inserting your documents in DB. You can then send that new data either after saving it in DB or at the time of insertion only.
2) Refer to this answer which talks about solving your problem using inbuilt functions provided by mongoDb. You can study in deep about them in mongoDb docs.
3) There is also another way to do this which includes listening to changes in log files. As you know everything done in mongo is recorded and logged in files so whenever there is some change in data you can know it from there also. You will have to do the digging by yourself in this method.
Hope it helps!
I am making an application using Ionic framework We are using Couchdb and pouchdb but when we do couchdb to pouchdb sync All the documents in Couchdb are replicating to every pouchdb user I am stucked please help me
You need to create a filtered function to replicate only documents you need.
Here the documentation from pouchdb: http://pouchdb.com/2015/04/05/filtered-replication.html
Usually for this case I create one database per user in couchdb and I replicate pouchdb only with the couchdb user database. So you don't have to deal with filtered function on pouchDB.
You will use filtered function to replicate couchdb user database to a master couchdb database.
Here the documentation for couchDB replication with filtering function: https://wiki.apache.org/couchdb/Replication#Filtered_Replication
I think your question is answered in that thread:
here
Good luck
Hi: I want to use a mobile CouchDB and a remote CouchDB. To transfer from mobile to remote DB I want to replicate the data. But for storage reasons I want to regularly delete old data from the mobile CouchDB and keep it on the remote CouchDB. As what I have seen local deletion will also be replicated. Is there any knowledge about how to handle this?
You should be able to use filtered replication, http://wiki.apache.org/couchdb/Replication#Filtered_Replication, with a filter function of:
function(doc) {
return !doc._deleted;
}