Snippets

Popina Sync Gateway Config File Channels 104.155.33.203

Updated by Thomas Hebert

File config.json Modified

  • Ignore whitespace
  • Hide word diff
      "server":"http://104.155.33.203:8091/",
      "bucket":"default",
      "users": {
-      "GUEST": {"disabled": false, "admin_channels": ["*"]}
+      "GUEST": {"disabled": true, "admin_channels": ["*"]}
       },
       "sync":`
 
Updated by Thomas Hebert

File config.json Modified

  • Ignore whitespace
  • Hide word diff
       "GUEST": {"disabled": false, "admin_channels": ["*"]}
       },
       "sync":`
-      function (doc, oldDoc) {
+
+function (doc, oldDoc) {
      if (!doc.owner) throw({forbidden : "Documents must have a owner"});
 
      var webChannelForOwner = 'webFor_' + doc.owner;
      var mobileChannelForOwner = 'mobileFor_' + doc.owner;
+     
      var restaurantForOwner = 'restaurantFor_' + doc.owner;
      var liveTillsForOwner = 'liveTillsFor_' + doc.owner;
      var pausedTillsForOwner = 'pausedTillsFor_' + doc.owner;
      var statsTillsForOwner = 'statsTillsFor_' + doc.owner;
 
-     
      var channels = [mobileChannelForOwner, webChannelForOwner];
 
      var restaurantTypes = [
                             // 'StatsShift',
                             // 'StatsTill',
                             // 'StatsTillPaymentTotal',
-                            // 'StockMovement',
+                            'StockMovement',
                             // 'TableOrder',
                             'Tax',
                             // 'Till',
                             'UnitPrice',
                             // 'UnitPriceOrder',
                             'UnitPriceType'
-                         ];
+                            ];
 
      // route channels
      if (restaurantTypes.indexOf(doc.type) !== -1) {
          channels.push(restaurantForOwner);
      }
      else {
-         if (doc.status === 0) {
+         if (doc.tillStatus === 0) {
               channels.push(liveTillsForOwner);
          }
-         else if (doc.status === 1) {
+         else if (doc.tillStatus === 1) {
               channels.push(pausedTillsForOwner);
          }
          else {
      }
 
      channel(channels);
-}
-`
+ }
+ `
    }
  }
 }
Updated by Thomas Hebert

File config.json Modified

  • Ignore whitespace
  • Hide word diff
      
      var channels = [mobileChannelForOwner, webChannelForOwner];
 
-     var restaurantTypes = ['Restaurant'];
+     var restaurantTypes = [
+                            'Account',
+                            'Carte',
+                            'CarteCategory',
+                            'CarteMacroCategory',
+                            'CarteTable',
+                            'Discount',
+                            'Item',
+                            // 'ItemOrder',
+                            'ItemStock',
+                            'Map',
+                            'Menu',
+                            // 'MenuOrder',
+                            'MenuPrice',
+                            // 'MenuPriceOrder',
+                            'MenuStep',
+                            'Option',
+                            'OptionCategory',
+                            // 'OptionOrder',
+                            // 'Order',
+                            // 'Payment',
+                            // 'PaymentItemOrder',
+                            // 'PaymentMenuOrder',
+                            'PaymentMethod',
+                            // 'PaymentOptionOrder',
+                            // 'PaymentSession',
+                            'Person',
+                            'PlaceOfPreparation',
+                            'PositionItemCategory',
+                            'PositionItemSelection',
+                            'PositionItemStepMenu',
+                            'PreparationStep',
+                            // 'PreparationStepOrder',
+                            'Printer',
+                            'Restaurant',
+                            'Room',
+                            'Selection',
+                            // 'Shift',
+                            // 'StatsDiscount',
+                            // 'StatsItem',
+                            // 'StatsMenu',
+                            // 'StatsOption',
+                            // 'StatsOrder',
+                            // 'StatsShift',
+                            // 'StatsTill',
+                            // 'StatsTillPaymentTotal',
+                            // 'StockMovement',
+                            // 'TableOrder',
+                            'Tax',
+                            // 'Till',
+                            'UnitPrice',
+                            // 'UnitPriceOrder',
+                            'UnitPriceType'
+                         ];
 
      // route channels
      if (restaurantTypes.indexOf(doc.type) !== -1) {
Updated by Thomas Hebert

File config.json Modified

  • Ignore whitespace
  • Hide word diff
       function (doc, oldDoc) {
      if (!doc.owner) throw({forbidden : "Documents must have a owner"});
 
-     var webOnly = [];
      var webChannelForOwner = 'webFor_' + doc.owner;
      var mobileChannelForOwner = 'mobileFor_' + doc.owner;
+     var restaurantForOwner = 'restaurantFor_' + doc.owner;
+     var liveTillsForOwner = 'liveTillsFor_' + doc.owner;
+     var pausedTillsForOwner = 'pausedTillsFor_' + doc.owner;
+     var statsTillsForOwner = 'statsTillsFor_' + doc.owner;
+
+     
+     var channels = [mobileChannelForOwner, webChannelForOwner];
+
+     var restaurantTypes = ['Restaurant'];
 
      // route channels
-     if (webOnly.indexOf(doc.type) !== -1) channel(webChannelForOwner);
-     else channel([mobileChannelForOwner, webChannelForOwner]);
+     if (restaurantTypes.indexOf(doc.type) !== -1) {
+         channels.push(restaurantForOwner);
+     }
+     else {
+         if (doc.status === 0) {
+              channels.push(liveTillsForOwner);
+         }
+         else if (doc.status === 1) {
+              channels.push(pausedTillsForOwner);
+         }
+         else {
+              channels.push(statsTillsForOwner);
+         }         
+     }
+
+     channel(channels);
 }
 `
    }
Created by Thomas Hebert

File config.json Added

  • Ignore whitespace
  • Hide word diff
+{
+ "interface":":4984",
+ "adminInterface":":4985",
+ "log": ["*"],
+   "databases": {
+    "database": {
+     "server":"http://104.155.33.203:8091/",
+     "bucket":"default",
+     "users": {
+      "GUEST": {"disabled": false, "admin_channels": ["*"]}
+      },
+      "sync":`
+      function (doc, oldDoc) {
+     if (!doc.owner) throw({forbidden : "Documents must have a owner"});
+
+     var webOnly = [];
+     var webChannelForOwner = 'webFor_' + doc.owner;
+     var mobileChannelForOwner = 'mobileFor_' + doc.owner;
+
+     // route channels
+     if (webOnly.indexOf(doc.type) !== -1) channel(webChannelForOwner);
+     else channel([mobileChannelForOwner, webChannelForOwner]);
+}
+`
+   }
+ }
+}
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.