create Collection
Creates a collection in an existing scope. Equivalent to:
createCollection(CollectionSpec(scopeName, collectionName, maxExpiry))
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 containing some collections
val manager: CollectionManager = bucket.collections
with(manager) {
val scopeName = "tenant-a"
createScope(scopeName)
createCollection(scopeName = scopeName, collectionName = "widgets")
createCollection(scopeName = scopeName, collectionName = "invoices")
println(getScope(scopeName))
}
//sampleEnd
}
Parameters
Name of the parent scope. This scope must already exist.
Name of the collection to create.
Maximum expiry for documents in the collection. Duration.ZERO (or null) means the collection's max expiry is always the same as the bucket's max expiry. If using Couchbase Server 7.6 or later, CollectionSpec.NEVER_EXPIRE (or -1 seconds) means documents in the collection never expire, regardless of the bucket's max expiry.
Throws
if the parent scope does not exist.
if there is already a collection with the same name in the parent scope.
Creates a collection in an existing scope.
Parameters
Specifies the collection to create. The parent scope must already exist.
Throws
if the parent scope does not exist.
if there is already a collection with the same name in the parent scope.