getScope

suspend fun getScope(scopeName: String, common: CommonOptions = CommonOptions.Default): ScopeSpec

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

scopeName

Name of the scope to inspect.

Throws

com.couchbase.client.core.error.ScopeNotFoundException

if the bucket does not have a scope with this name.