-
-
Save derekdon/349ff3d95197e2d66578 to your computer and use it in GitHub Desktop.
Sync Gateway Config (Original Couchbase Cluster Go)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"log": ["CRUD", "HTTP+", "Access"], | |
"CORS": { | |
"origin": ["http://localhost:8080", "http://localhost:9000", "http://localhost:3000"], | |
"loginOrigin": ["http://localhost:8080", "http://localhost:9000", "http://localhost:3000"], | |
"headers": ["Content-Type"], | |
"maxAge": 17280000 | |
}, | |
"databases": { | |
"mm": { | |
"server":"http://{{ .COUCHBASE_SERVER_IP }}:8091", | |
"bucket":"mm", | |
"users": { | |
"GUEST": {"disabled": true} | |
}, | |
"revsLimit" : 3, | |
"sync": ` | |
function(doc, oldDoc) { | |
if (doc._deleted) { | |
// Only document owners can delete documents | |
requireUser(oldDoc.owner); | |
// Skip other validation because a deletion has no other properties: | |
return; | |
} | |
// Required properties: | |
if (!doc.jsonType || !doc.owner || !doc.channels) { | |
throw({forbidden: 'Missing required properties'}); | |
} | |
// The 'owner' property must match the user creating the document, | |
// and only document owners can change documents | |
requireUser(oldDoc ? oldDoc.owner : doc.owner); | |
// The 'owner' property is immutable: | |
if (oldDoc && doc.owner !== oldDoc.owner) { | |
throw({forbidden: 'Cannot change owner'}); | |
} | |
// Finally, assign the document to the channels in the list: | |
channel(doc.channels); | |
} | |
` | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment