- {
- "interface":":4984",
- "adminInterface":":4985",
- "log":["*"],
- "logFilePath": "/Users/upurusa/tools/couchbase/couchbase-sync-gateway-1.3.0/logs/cb-sync-gateway.log",
- "compressResponses": false,
- "databases": {
- "realize-reader": {
- "server":"http://localhost:8091",
- "event_handlers": {
- "max_processes": 500,
- "wait_for_process": "100",
- "document_changed": [
- {
- "handler": "webhook",
- "url": "https://hookb.in/Z6m7kLVx"
- }
- ]
- },
- "bucket":"realize-reader",
- "sync": `function (doc, oldDoc) {
- if(!oldDoc) {
- if(doc && doc.type && doc.userId) {
- requireUser(doc.userId);
- channel("user_" + doc.userId);
- } else {
- throw ({forbidden: "Document type and userId must be specified"});
- }
- } else {
- if(oldDoc.type && oldDoc.userId) {
- requireUser(oldDoc.userId);
- channel("user_" + oldDoc.userId);
- } else if(oldDoc._deleted && doc.type && doc.userId) {
- requireUser(doc.userId);
- channel("user_" + doc.userId);
- } else {
- throw ({forbidden: "Document type and userId must be specified"});
- }
- }
- }`,
- "users": {
- "GUEST": {
- "disabled": true,
- "admin_channels": ["*"]
- },
- "admin": {
- "admin_channels": ["*"],
- "password": "testing123$"
- }
- }
- },
- "rr-test": {
- "server":"http://rr-test:testing123$@localhost:8091",
- "event_handlers": {
- "max_processes": 500,
- "wait_for_process": "100",
- "document_changed": [
- {
- "handler": "webhook",
- "url": "https://hookb.in/Z6m7kLVx"
- }
- ]
- },
- "bucket":"rr-test",
- "sync": `function(doc, oldDoc) {
- //console.log("doc.ugc_timestamp : ", doc.ugc_timestamp);
- //console.log("oldDoc.ugc_timestamp : ", oldDoc.ugc_timestamp);
- //doc_ugc_time = new Date(doc.ugc_timestamp);
- //oldDoc_ugc_time = new Date(oldDoc.ugc_timestamp);
- // time stamp in ISO format: 2016-08-30T18:10:32.697Z");
- // console.log("current timestamp : ", new Date().toISOString());
- //if ((doc_ugc_time - oldDoc_ugc_time) == 0) {
- //console.log("new doc timestamp = the old doc timestamp so persisting the new document in the server");
- //} else if (doc_ugc_time > oldDoc_ugc_time) {
- //console.log("new doc timestamp > the old doc timestamp so persisting the new document in the server");
- //} else {
- //console.log("new doc timestamp < the old doc timestamp in the server, do discarding new doc");
- //throw({forbidden: "The document saved seems to be a old document, having old time stamp"})
- //}
- channel(doc.channels);
- }`,
- "users": {
- "GUEST": {
- "disabled": true,
- "admin_channels": ["*"]
- },
- "admin": {
- "admin_channels": ["*"],
- "password": "testing123$"
- }
- }
- }
- }
- }
Stikked
