Update Handlers for couchdb to be invoked from pouchbd
Info
- Environment: Hybrid App
- Platform: Android
- Adapter: IndexedDB
- Server: CouchDB&PouchDB Server
Hello , I have been trying to implement the design document update_handler in couchdb to be utilized when the pouchdb data syncs and is stored in the couchdb .
Aim is to verify the storage of data in the central CouchDB. This is required to as for the security verification and other functionality implementation. I have tried using pouchdb-update plugin but can get a concrete way to achieve is below is the design doc and the code that will invoke the updates function on couchdb when data is synced to the couchdb.
{
"_id": "_design/secure",
"_rev": "27-d7fbdd8ea925df711d2d4329dbb032c2",
"language": "javascript",
"updates": {
"update": "function(doc,req){if(!doc)return[null,'Doc doesnt exists! Please Create a new
document']doc.secured = doc.secured == false?true:false;return [doc,'Ok,Secured']}"
}
}
And I want to invoke it to modifiy my docs once it is stored in couchdb . The docs will be syncing from the pouchdb that is running in a cordova app background . This is what I have tried to implement including POUCHDB-UPDATE plugin.
var argv = require('minimist')(process.argv.slice(2));
var logLocation=argv.pouchlog;
var controlFileHandler=argv.controlfh;
var express = require('express')
var app = express()
var PouchDB = require('pouchdb').plugin('pouchdb-update');
let InMemPouchDB = PouchDB.defaults({db: require("memdown"), migrate: false})
app.use('', require('express-pouchdb')(InMemPouchDB,
{mode:'minimumForPouchDB',logPath:logLocation}))
app.listen(3005)
var db = new InMemPouchDB('todos',{revs_limits: 1});
var remoteCouch = 'http://127.0.0.1:5984/todos';
db.changes({live: true}).on('change', function(){
db.sync(remoteCouch,{live:true,retry:true}).on('active',function(){
db.update('_design/secure', function(res){
console.log("Data Secured");
console.log(res);
})
})
But its not working I am having problem to invoke the updates function on the couchdb, Please can you guys help me in the implementation . The aim is to trigger the update_handler function only when the data is stored in the Couchdb ( and indicates the data syncing between multiple pouchdb is not secure unless it is stored in the couchdb ). Please help me solve the issue or if there is any simpler way to achieve this, any help will be deeply appreciated.
javascript node.js couchdb pouchdb nano
add a comment |
Info
- Environment: Hybrid App
- Platform: Android
- Adapter: IndexedDB
- Server: CouchDB&PouchDB Server
Hello , I have been trying to implement the design document update_handler in couchdb to be utilized when the pouchdb data syncs and is stored in the couchdb .
Aim is to verify the storage of data in the central CouchDB. This is required to as for the security verification and other functionality implementation. I have tried using pouchdb-update plugin but can get a concrete way to achieve is below is the design doc and the code that will invoke the updates function on couchdb when data is synced to the couchdb.
{
"_id": "_design/secure",
"_rev": "27-d7fbdd8ea925df711d2d4329dbb032c2",
"language": "javascript",
"updates": {
"update": "function(doc,req){if(!doc)return[null,'Doc doesnt exists! Please Create a new
document']doc.secured = doc.secured == false?true:false;return [doc,'Ok,Secured']}"
}
}
And I want to invoke it to modifiy my docs once it is stored in couchdb . The docs will be syncing from the pouchdb that is running in a cordova app background . This is what I have tried to implement including POUCHDB-UPDATE plugin.
var argv = require('minimist')(process.argv.slice(2));
var logLocation=argv.pouchlog;
var controlFileHandler=argv.controlfh;
var express = require('express')
var app = express()
var PouchDB = require('pouchdb').plugin('pouchdb-update');
let InMemPouchDB = PouchDB.defaults({db: require("memdown"), migrate: false})
app.use('', require('express-pouchdb')(InMemPouchDB,
{mode:'minimumForPouchDB',logPath:logLocation}))
app.listen(3005)
var db = new InMemPouchDB('todos',{revs_limits: 1});
var remoteCouch = 'http://127.0.0.1:5984/todos';
db.changes({live: true}).on('change', function(){
db.sync(remoteCouch,{live:true,retry:true}).on('active',function(){
db.update('_design/secure', function(res){
console.log("Data Secured");
console.log(res);
})
})
But its not working I am having problem to invoke the updates function on the couchdb, Please can you guys help me in the implementation . The aim is to trigger the update_handler function only when the data is stored in the Couchdb ( and indicates the data syncing between multiple pouchdb is not secure unless it is stored in the couchdb ). Please help me solve the issue or if there is any simpler way to achieve this, any help will be deeply appreciated.
javascript node.js couchdb pouchdb nano
add a comment |
Info
- Environment: Hybrid App
- Platform: Android
- Adapter: IndexedDB
- Server: CouchDB&PouchDB Server
Hello , I have been trying to implement the design document update_handler in couchdb to be utilized when the pouchdb data syncs and is stored in the couchdb .
Aim is to verify the storage of data in the central CouchDB. This is required to as for the security verification and other functionality implementation. I have tried using pouchdb-update plugin but can get a concrete way to achieve is below is the design doc and the code that will invoke the updates function on couchdb when data is synced to the couchdb.
{
"_id": "_design/secure",
"_rev": "27-d7fbdd8ea925df711d2d4329dbb032c2",
"language": "javascript",
"updates": {
"update": "function(doc,req){if(!doc)return[null,'Doc doesnt exists! Please Create a new
document']doc.secured = doc.secured == false?true:false;return [doc,'Ok,Secured']}"
}
}
And I want to invoke it to modifiy my docs once it is stored in couchdb . The docs will be syncing from the pouchdb that is running in a cordova app background . This is what I have tried to implement including POUCHDB-UPDATE plugin.
var argv = require('minimist')(process.argv.slice(2));
var logLocation=argv.pouchlog;
var controlFileHandler=argv.controlfh;
var express = require('express')
var app = express()
var PouchDB = require('pouchdb').plugin('pouchdb-update');
let InMemPouchDB = PouchDB.defaults({db: require("memdown"), migrate: false})
app.use('', require('express-pouchdb')(InMemPouchDB,
{mode:'minimumForPouchDB',logPath:logLocation}))
app.listen(3005)
var db = new InMemPouchDB('todos',{revs_limits: 1});
var remoteCouch = 'http://127.0.0.1:5984/todos';
db.changes({live: true}).on('change', function(){
db.sync(remoteCouch,{live:true,retry:true}).on('active',function(){
db.update('_design/secure', function(res){
console.log("Data Secured");
console.log(res);
})
})
But its not working I am having problem to invoke the updates function on the couchdb, Please can you guys help me in the implementation . The aim is to trigger the update_handler function only when the data is stored in the Couchdb ( and indicates the data syncing between multiple pouchdb is not secure unless it is stored in the couchdb ). Please help me solve the issue or if there is any simpler way to achieve this, any help will be deeply appreciated.
javascript node.js couchdb pouchdb nano
Info
- Environment: Hybrid App
- Platform: Android
- Adapter: IndexedDB
- Server: CouchDB&PouchDB Server
Hello , I have been trying to implement the design document update_handler in couchdb to be utilized when the pouchdb data syncs and is stored in the couchdb .
Aim is to verify the storage of data in the central CouchDB. This is required to as for the security verification and other functionality implementation. I have tried using pouchdb-update plugin but can get a concrete way to achieve is below is the design doc and the code that will invoke the updates function on couchdb when data is synced to the couchdb.
{
"_id": "_design/secure",
"_rev": "27-d7fbdd8ea925df711d2d4329dbb032c2",
"language": "javascript",
"updates": {
"update": "function(doc,req){if(!doc)return[null,'Doc doesnt exists! Please Create a new
document']doc.secured = doc.secured == false?true:false;return [doc,'Ok,Secured']}"
}
}
And I want to invoke it to modifiy my docs once it is stored in couchdb . The docs will be syncing from the pouchdb that is running in a cordova app background . This is what I have tried to implement including POUCHDB-UPDATE plugin.
var argv = require('minimist')(process.argv.slice(2));
var logLocation=argv.pouchlog;
var controlFileHandler=argv.controlfh;
var express = require('express')
var app = express()
var PouchDB = require('pouchdb').plugin('pouchdb-update');
let InMemPouchDB = PouchDB.defaults({db: require("memdown"), migrate: false})
app.use('', require('express-pouchdb')(InMemPouchDB,
{mode:'minimumForPouchDB',logPath:logLocation}))
app.listen(3005)
var db = new InMemPouchDB('todos',{revs_limits: 1});
var remoteCouch = 'http://127.0.0.1:5984/todos';
db.changes({live: true}).on('change', function(){
db.sync(remoteCouch,{live:true,retry:true}).on('active',function(){
db.update('_design/secure', function(res){
console.log("Data Secured");
console.log(res);
})
})
But its not working I am having problem to invoke the updates function on the couchdb, Please can you guys help me in the implementation . The aim is to trigger the update_handler function only when the data is stored in the Couchdb ( and indicates the data syncing between multiple pouchdb is not secure unless it is stored in the couchdb ). Please help me solve the issue or if there is any simpler way to achieve this, any help will be deeply appreciated.
javascript node.js couchdb pouchdb nano
javascript node.js couchdb pouchdb nano
edited Nov 15 '18 at 8:53
Bishal Sahoo
asked Nov 14 '18 at 13:27
Bishal SahooBishal Sahoo
117
117
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301340%2fupdate-handlers-for-couchdb-to-be-invoked-from-pouchbd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301340%2fupdate-handlers-for-couchdb-to-be-invoked-from-pouchbd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown