Skip to content

Instantly share code, notes, and snippets.

@derekdon
Last active September 11, 2015 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekdon/349ff3d95197e2d66578 to your computer and use it in GitHub Desktop.
Save derekdon/349ff3d95197e2d66578 to your computer and use it in GitHub Desktop.
Sync Gateway Config (Original Couchbase Cluster Go)
{
"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