From Burly Crow, 9 Years ago, written in Plain Text.
Embed
  1. {
  2.   "interface":":4984",
  3.   "adminInterface":":4985",
  4.   "log":["*"],
  5.   "logFilePath": "/Users/upurusa/tools/couchbase/couchbase-sync-gateway-1.3.0/logs/cb-sync-gateway.log",
  6.   "compressResponses": false,
  7.   "databases": {
  8.     "realize-reader": {
  9.       "server":"http://localhost:8091",
  10.       "event_handlers": {
  11.         "max_processes": 500,
  12.         "wait_for_process": "100",
  13.         "document_changed": [
  14.           {
  15.             "handler": "webhook",
  16.             "url": "https://hookb.in/Z6m7kLVx"
  17.           }
  18.         ]
  19.       },
  20.       "bucket":"realize-reader",
  21.       "sync": `function (doc, oldDoc) {
  22.           if(!oldDoc) {
  23.             if(doc && doc.type && doc.userId) {
  24.               requireUser(doc.userId);
  25.               channel("user_" + doc.userId);
  26.             } else {
  27.               throw ({forbidden: "Document type and userId must be specified"});
  28.             }
  29.           } else {
  30.             if(oldDoc.type && oldDoc.userId) {
  31.               requireUser(oldDoc.userId);
  32.               channel("user_" + oldDoc.userId);
  33.             } else if(oldDoc._deleted && doc.type && doc.userId) {
  34.               requireUser(doc.userId);
  35.               channel("user_" + doc.userId);
  36.             } else {
  37.               throw ({forbidden: "Document type and userId must be specified"});
  38.             }
  39.           }
  40.       }`,
  41.       "users": {
  42.           "GUEST": {
  43.             "disabled": true,
  44.             "admin_channels": ["*"]
  45.           },
  46.           "admin": {
  47.             "admin_channels": ["*"],
  48.             "password": "testing123$"
  49.           }
  50.       }
  51.     },
  52.  
  53.     "rr-test": {
  54.       "server":"http://rr-test:testing123$@localhost:8091",
  55.       "event_handlers": {
  56.         "max_processes": 500,
  57.         "wait_for_process": "100",
  58.         "document_changed": [
  59.           {
  60.             "handler": "webhook",
  61.             "url": "https://hookb.in/Z6m7kLVx"
  62.           }
  63.         ]
  64.       },
  65.       "bucket":"rr-test",
  66.       "sync": `function(doc, oldDoc) {
  67.         //console.log("doc.ugc_timestamp : ", doc.ugc_timestamp);
  68.         //console.log("oldDoc.ugc_timestamp : ", oldDoc.ugc_timestamp);
  69.  
  70.         //doc_ugc_time = new Date(doc.ugc_timestamp);
  71.         //oldDoc_ugc_time = new Date(oldDoc.ugc_timestamp);
  72.  
  73.         // time stamp in ISO format:   2016-08-30T18:10:32.697Z");
  74.         // console.log("current timestamp : ", new Date().toISOString());
  75.  
  76.         //if ((doc_ugc_time - oldDoc_ugc_time) == 0) {
  77.           //console.log("new doc timestamp = the old doc timestamp so persisting the new document in the server");
  78.         //} else if (doc_ugc_time > oldDoc_ugc_time) {
  79.           //console.log("new doc timestamp > the old doc timestamp so persisting the new document in the server");
  80.         //} else {
  81.           //console.log("new doc timestamp < the old doc timestamp in the server, do discarding new doc");
  82.           //throw({forbidden: "The document saved seems to be a old document, having old time stamp"})
  83.         //}
  84.  
  85.         channel(doc.channels);
  86.       }`,
  87.       "users": {
  88.           "GUEST": {
  89.             "disabled": true,
  90.             "admin_channels": ["*"]
  91.           },
  92.           "admin": {
  93.             "admin_channels": ["*"],
  94.             "password": "testing123$"
  95.           }
  96.       }
  97.     }
  98.  
  99.   }
  100. }