Snippets
Revised by
Thomas Hebert
ea5b3d7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | {
"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 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 = [
'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) {
channels.push(restaurantForOwner);
}
else {
if (doc.tillStatus === 0) {
channels.push(liveTillsForOwner);
}
else if (doc.tillStatus === 1) {
channels.push(pausedTillsForOwner);
}
else {
channels.push(statsTillsForOwner);
}
}
channel(channels);
}
`
}
}
}
|
You can clone a snippet to your computer for local editing. Learn more.