datastax / astra-db-ts

Typescript client for Astra DB Vector
https://npmjs.com/@datastax/astra-db-ts
Apache License 2.0
13 stars 6 forks source link

`createCollection` is not idempotent #27

Closed TejasQ closed 4 months ago

TejasQ commented 4 months ago

Given this code snippet:

image

I get this error:

image

My workaround is to actually make it idempotent and not raise an error by wrapping the call to createCollection in a try/catch block and swallowing the error. When I do this, everything continues as normal.

Current status: calling createCollection on an existing collection raises an error when the documentation says it does not. Expected: no error if collection already exists.

There is no difference in configuration.

toptobes commented 4 months ago

Apologies, looks like that's somewhat out of date ts-doc—if you pass checkExists: false, it should work as expected

e.g.

const collection = await db.createCollection(collectionName, {
  vector: {
    dimension: 1024,
  },
  checkExists: false,
});

It'll be fixed in the next patch version, thanks for bringing this to our attention!

It's at least properly documented in the official docs

toptobes commented 4 months ago

tsdoc tweaked in 1.0.1