get Scope
suspend fun getScope(scopeName: String, common: CommonOptions = CommonOptions.Default): ScopeSpec
Content copied to clipboard
Returns information about a scope and its collections.
Samples
import com.couchbase.client.kotlin.Bucket
import com.couchbase.client.kotlin.manager.collection.CollectionManager
import com.couchbase.client.kotlin.manager.collection.ScopeSpec
fun main() {
//sampleStart
// Create a new scope using an existing scope as a template.
// (The new scope will have collections with the same names
// as the template's collections.)
val manager: CollectionManager = bucket.collections
val templateScopeSpec: ScopeSpec = manager.getScope("existing-scope")
val nameOfNewScope = "new-scope"
manager.createScope(nameOfNewScope)
templateScopeSpec.collections
.filter { it.name != "_default" } // can't create default collection
.forEach { manager.createCollection(it.copy(scopeName = nameOfNewScope)) }
//sampleEnd
}
Parameters
scope Name
Name of the scope to inspect.
Throws
com. couchbase. client. core. error. Scope Not Found Exception
if the bucket does not have a scope with this name.