Details
-
Bug
-
Resolution: Fixed
-
Blocker
-
None
-
None
-
None
-
1
-
Critical
Description
What was Done : We attempted to create collection using Node.js SDK (latest) and Legacy Database. (Database which doesnt have a support for Scopes and Collections)
What is Expected : Error something like “ Unsupported Feature Exception ” .
What was Observed : Error: failed to create collection
Problem Statement : What is currently thrown is a more generic exception “failed to create collection” which is very much likely to happen in 7.0. for various reason. There needs to be a more specific error message returned back to the developer so that they can make better decisions. Needed in situations like Ottoman to determine the next course of action.
Below is code that we used.
const couchbase = require("couchbase"); |
const CollectionExistsError = require("couchbase").CollectionExistsError |
const cluster = new couchbase.Cluster("couchbase://localhost", { |
username: "Administrator", |
password: "password", |
})
|
|
// Open a bucket to allow cluster-level querying
|
var bucket = cluster.bucket('travel') |
// var collection = bucket.collection('Airline')
|
const createCollection = async () => {
|
try { |
await bucket.collections().createCollection({
|
name: 'Airlinez', |
scopeName: '_default', |
maxExpiry: 500,
|
})
|
} catch(e) { |
console.error(e.message) }}
|
|
createCollection()
|
.catch((e) => { |
if (!(e instanceof CollectionExistsError)) { |
console.error(e);
|
}
|
})
|
|
|