From 3beea7d818fda050e5dd0cb6480c8f5c3870e717 Mon Sep 17 00:00:00 2001 From: Tor Colvin Date: Wed, 10 May 2023 10:50:24 -0400 Subject: [PATCH] CBG-2916 Add database examples with scopes (#6233) --- .../collections-with-custom-scope.json | 38 +++++++++++++++++++ .../collections-with-default-collection.json | 38 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 examples/database_config/collections-with-custom-scope.json create mode 100644 examples/database_config/collections-with-default-collection.json diff --git a/examples/database_config/collections-with-custom-scope.json b/examples/database_config/collections-with-custom-scope.json new file mode 100644 index 0000000000..5d7a6c4bb6 --- /dev/null +++ b/examples/database_config/collections-with-custom-scope.json @@ -0,0 +1,38 @@ +{ + "name": "db", + "bucket": "bucket", + "scopes" : { + "scope1": { + "collections": { + "collection1" : { + "sync": ` + function(doc, oldDoc, meta) { + if (doc.type != "default") { + throw({forbidden : "Rejected document"}) + } + channel("legacy") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + }, + "collection2" : { + "sync": ` + function(doc, oldDoc, meta) { + channel("collection1") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + } + } + } + }, + "num_index_replicas": 0 +} diff --git a/examples/database_config/collections-with-default-collection.json b/examples/database_config/collections-with-default-collection.json new file mode 100644 index 0000000000..907b1f659f --- /dev/null +++ b/examples/database_config/collections-with-default-collection.json @@ -0,0 +1,38 @@ +{ + "name": "db", + "bucket": "bucket", + "scopes" : { + "_default": { + "collections": { + "_default" : { + "sync": ` + function(doc, oldDoc, meta) { + if (doc.collection != "default") { + throw({forbidden : "Rejected document"}) + } + channel("legacy") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + }, + "collection1" : { + "sync": ` + function(doc, oldDoc, meta) { + channel("collection1") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + } + } + } + }, + "num_index_replicas": 0 +}