## API Reference ## Classes
Collection operations supported by the driver. This class is called "Collection" for consistency with Mongoose, because
in Mongoose a Collection is the interface that Models and Queries use to communicate with the database. However, from
an Astra perspective, this class can be a wrapper around a Collection or a Table depending on the corresponding db's
isTable option. Needs to be a separate class because Mongoose only supports one collection class.
Extends Mongoose's Connection class to provide compatibility with Data API. Responsible for maintaining the connection to Data API.
Defines the base database class for interacting with Astra DB. Responsible for creating collections and tables. This class abstracts the operations for both collections mode and tables mode. There is a separate TablesDb class for tables and CollectionsDb class for collections.
MongooseSet is a Mongoose-specific wrapper around vanilla JavaScript sets
that represents a Cassandra set. It wraps a JavaScript Set and integrates with
Mongoose change tracking.
Takes 2 generic types: RawType and HydratedType. The RawType is the type of the value
stored in the database, while the HydratedType is the type of the value when it is
retrieved from the database - these are the same type for primitive types, but
are different for Mongoose subdocuments.
Add and delete operations use atomic updates ($push, $pullAll) when possible,
and only fall back to a full overwrite ($set) when there is a mixed sequence of operations.
SchemaSet is a custom Mongoose SchemaType that allows you to use Cassandra sets in tables mode.
A Set path translates to type: 'set' in the Data API.
Vectorize is a custom Mongoose SchemaType that allows you set a vector value to a string for tables mode vectorize API. A Vectorize path is an array of numbers that can also be set to a string.
Base class for astra-mongoose-specific errors.
BaseDbDb instance that creates and manages collections.
BaseDbDb instance that creates and manages tables.
Mongoose plugin to handle adding $vector to the projection by default if $vector has select: true.
Because $vector is deselected by default, this plugin makes it possible for the user to include $vector
by default from their schema.
You do not need to call this function directly. Mongoose applies this plugin automatically when you call setDriver().
Mongoose plugin to validate arrays of numbers that have a dimension property. Ensure that the array
is either nullish or has a length equal to the dimension.
You do not need to call this function directly. Mongoose applies this plugin automatically when you call setDriver().
Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()
Given a Mongoose schema, get the definitions of all the UDTs used by this schema. Used to create all UDTs required by the schema before creating the table.
Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()
Create an Astra connection URI while connecting to Astra Data API.
Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()
Collection operations supported by the driver. This class is called "Collection" for consistency with Mongoose, because
in Mongoose a Collection is the interface that Models and Queries use to communicate with the database. However, from
an Astra perspective, this class can be a wrapper around a Collection or a Table depending on the corresponding db's
isTable option. Needs to be a separate class because Mongoose only supports one collection class.
Count documents in the collection that match the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
### collection.find(filter, options, callback)
Find documents in the collection that match the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| options |
| callback |
### collection.findOne(filter, options)
Find a single document in the collection that matches the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| options |
### collection.insertOne(doc)
Insert a single document into the collection.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| doc |
### collection.insertMany(documents, options)
Insert multiple documents into the collection.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| documents |
| options |
### collection.findOneAndUpdate(filter, update, options)
Update a single document in a collection.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| update |
| options |
### collection.findOneAndDelete(filter, options)
Find a single document in the collection and delete it.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| options |
### collection.findOneAndReplace(filter, newDoc, options)
Find a single document in the collection and replace it.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| newDoc |
| options |
### collection.deleteMany(filter)
Delete one or more documents in a collection that match the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
### collection.deleteOne(filter, options, callback)
Delete a single document in a collection that matches the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| options |
| callback |
### collection.replaceOne(filter, replacement, options)
Update a single document in a collection that matches the given filter, replacing it with replacement.
Converted to a findOneAndReplace() under the hood.
Collection](#Collection)
| Param |
| --- |
| filter |
| replacement |
| options |
### collection.updateOne(filter, update, options)
Update a single document in a collection that matches the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| update |
| options |
### collection.updateMany(filter, update, options)
Update multiple documents in a collection that match the given filter.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| update |
| options |
### collection.estimatedDocumentCount()
Get the estimated number of documents in a collection based on collection metadata
**Kind**: instance method of [Collection](#Collection)
### collection.syncTable(definition, createTableOptions, dryRun) ⇒
Sync the underlying table schema with the specified definition: creates a new table if one doesn't exist, or alters the existing table to match the definition by adding or dropping columns as necessary.
Note that modifying an existing column is NOT supported and will throw an error.
**Kind**: instance method of [Collection](#Collection)
**Returns**: An object with details of the planned or applied changes, including columnsToAdd, columnsToDrop, and createdNewTable.
| Param | Description | | --- | --- | | definition |new table definition (strict only)
| | createTableOptions |passed to createTable if the table doesn't exist
| | dryRun |if true, don't actually perform the operation, just return info on what would happen
| ### collection.alterTable(operation)Alter the underlying table with the specified name and operation - can add or drop columns
**Kind**: instance method of [Collection](#Collection)
| Param | Description |
| --- | --- |
| operation | add/drop
| ### collection.runCommand(command)Run an arbitrary command against this collection
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| command |
### collection.bulkWrite(ops, options)
Bulk write not supported.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| ops |
| options |
### collection.aggregate(pipeline, options)
Aggregate not supported.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| pipeline |
| options |
### collection.listIndexes()
Returns a list of all indexes on the collection. Returns a pseudo-cursor for Mongoose compatibility. Only works in tables mode, throws an error in collections mode.
**Kind**: instance method of [Collection](#Collection)
### collection.createIndex(indexSpec, options)
Create a new index. Only works in tables mode, throws an error in collections mode.
**Kind**: instance method of [Collection](#Collection)
| Param | Description |
| --- | --- |
| indexSpec | MongoDB-style index spec for Mongoose compatibility
| | options | | ### collection.dropIndex(name)Drop an existing index by name. Only works in tables mode, throws an error in collections mode.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| name |
### collection.findAndRerank(filter, options)
Finds documents that match the filter and reranks them based on the provided options.
**Kind**: instance method of [Collection](#Collection)
| Param |
| --- |
| filter |
| options |
## Connection
Extends Mongoose's Connection class to provide compatibility with Data API. Responsible for maintaining the connection to Data API.
**Kind**: global class * [Connection](#Connection) * [.debug](#Connection+debug) * [.collection(name, options)](#Connection+collection) * [.createCollection(name, options)](#Connection+createCollection) * [.createTable(name, definition)](#Connection+createTable) * [.dropCollection(name)](#Connection+dropCollection) * [.dropTable(name)](#Connection+dropTable) * [.createKeyspace(name)](#Connection+createKeyspace) * [.listCollections()](#Connection+listCollections) * [.listTables()](#Connection+listTables) * [.listTypes()](#Connection+listTypes) ⇒ * [.createType(name, definition)](#Connection+createType) ⇒Promise.<TypeDescriptor>
* [.dropType(name)](#Connection+dropType) ⇒
* [.alterType(name, update)](#Connection+alterType) ⇒
* [.syncTypes(types)](#Connection+syncTypes) ⇒
* [.runCommand(command)](#Connection+runCommand)
* [.listDatabases()](#Connection+listDatabases)
* [.openUri(uri, options)](#Connection+openUri)
* [.createClient(uri, options)](#Connection+createClient)
* [.asPromise()](#Connection+asPromise)
### connection.debug
Get current debug setting, accounting for potential changes to global debug config (mongoose.set('debug', true | false))
Connection](#Connection)
### connection.collection(name, options)
Get a collection by name. Cached in this.collections.
Connection](#Connection)
| Param |
| --- |
| name |
| options |
### connection.createCollection(name, options)
Create a new collection in the database
**Kind**: instance method of [Connection](#Connection)
| Param | Description |
| --- | --- |
| name | The name of the collection to create
| | options | | ### connection.createTable(name, definition)Create a new table in the database
**Kind**: instance method of [Connection](#Connection)
| Param |
| --- |
| name |
| definition |
### connection.dropCollection(name)
Drop a collection from the database
**Kind**: instance method of [Connection](#Connection)
| Param |
| --- |
| name |
### connection.dropTable(name)
Drop a table from the database
**Kind**: instance method of [Connection](#Connection)
| Param | Description |
| --- | --- |
| name | The name of the table to drop
| ### connection.createKeyspace(name)Create a new keyspace.
**Kind**: instance method of [Connection](#Connection)
| Param | Description |
| --- | --- |
| name | The name of the keyspace to create
| ### connection.listCollections()List all collections in the database
**Kind**: instance method of [Connection](#Connection)
### connection.listTables()
List all tables in the database
**Kind**: instance method of [Connection](#Connection)
### connection.listTypes() ⇒
List all user-defined types (UDTs) in the database.
**Kind**: instance method of [Connection](#Connection)
**Returns**: An array of type descriptors.
### connection.createType(name, definition) ⇒Promise.<TypeDescriptor>
Create a new user-defined type (UDT) with the specified name and fields definition.
**Kind**: instance method of [Connection](#Connection)
**Returns**: Promise.<TypeDescriptor> - The created type descriptor.
| Param | Description | | --- | --- | | name |The name of the type to create.
| | definition |The definition of the fields for the type.
| ### connection.dropType(name) ⇒Drop (delete) a user-defined type (UDT) by name.
**Kind**: instance method of [Connection](#Connection)
**Returns**: The result of the dropType command.
| Param | Description | | --- | --- | | name |The name of the type to drop.
| ### connection.alterType(name, update) ⇒Alter a user-defined type (UDT) by renaming or adding fields.
**Kind**: instance method of [Connection](#Connection)
**Returns**: The result of the alterType command.
| Param | Description | | --- | --- | | name |The name of the type to alter.
| | update |The alterations to be made: renaming or adding fields.
| ### connection.syncTypes(types) ⇒Synchronizes the set of user-defined types (UDTs) in the database. It makes existing types in the database
match the list provided by types. New types that are missing are created, and types that exist in the database
but are not in the input list are dropped. If a type is present in both, we add all the new type's fields to the existing type.
Connection](#Connection)
**Returns**: An object describing which types were created, updated, or dropped.
**Throws**: - [AstraMongooseError](#AstraMongooseError) If an error occurs during type synchronization, with partial progress information in the error.
| Param | Description | | --- | --- | | types |An array of objects each specifying the name and CreateTypeDefinition for a UDT to synchronize.
| ### connection.runCommand(command)Run an arbitrary Data API command on the database
**Kind**: instance method of [Connection](#Connection)
| Param | Description |
| --- | --- |
| command | The command to run
| ### connection.listDatabases()List all keyspaces. Called "listDatabases" for Mongoose compatibility
**Kind**: instance method of [Connection](#Connection)
### connection.openUri(uri, options)
Logic for creating a connection to Data API. Mongoose calls openUri() internally when the
user calls mongoose.create() or mongoose.createConnection(uri)
Connection](#Connection)
| Param | Description |
| --- | --- |
| uri | the connection string
| | options | | ### connection.createClient(uri, options)Create an astra-db-ts client and corresponding objects: client, db, admin.
**Kind**: instance method of [Connection](#Connection)
| Param | Description |
| --- | --- |
| uri | the connection string
| | options | | ### connection.asPromise()For consistency with Mongoose's API. mongoose.createConnection(uri) returns the connection, not a promise,
so the Mongoose pattern to call createConnection() and wait for connection to succeed is
await createConnection(uri).asPromise()
Connection](#Connection)
## BaseDb
Defines the base database class for interacting with Astra DB. Responsible for creating collections and tables. This class abstracts the operations for both collections mode and tables mode. There is a separate TablesDb class for tables and CollectionsDb class for collections.
**Kind**: global class * [BaseDb](#BaseDb) * [new BaseDb()](#new_BaseDb_new) * [.createTable(name, definition)](#BaseDb+createTable) * [.dropCollection(name)](#BaseDb+dropCollection) * [.dropTable(name)](#BaseDb+dropTable) * [.listCollections(options)](#BaseDb+listCollections) * [.listTables()](#BaseDb+listTables) * [.listTypes()](#BaseDb+listTypes) ⇒ * [.createType(name, definition)](#BaseDb+createType) ⇒ * [.dropType(name)](#BaseDb+dropType) ⇒ * [.alterType(name, update)](#BaseDb+alterType) ⇒ * [.syncTypes(types)](#BaseDb+syncTypes) ⇒ * [.command(command)](#BaseDb+command) ### new BaseDb()Whether we're using "tables mode" or "collections mode". If tables mode, then collection() returns
a Table instance, not a Collection instance. Also, if tables mode, createCollection() throws an
error for Mongoose syncIndexes() compatibility reasons.
Create a new table with the specified name and definition
**Kind**: instance method of [BaseDb](#BaseDb)
| Param |
| --- |
| name |
| definition |
### baseDb.dropCollection(name)
Drop a collection by name.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| name | The name of the collection to be dropped.
| ### baseDb.dropTable(name)Drop a table by name. This function does not throw an error if the table does not exist.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param |
| --- |
| name |
### baseDb.listCollections(options)
List all collections in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| options | Additional options for listing collections.
| ### baseDb.listTables()List all tables in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
### baseDb.listTypes() ⇒
List all user-defined types (UDTs) in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: An array of type descriptors.
### baseDb.createType(name, definition) ⇒Create a new user-defined type (UDT) with the specified name and fields definition.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the createType command.
| Param | Description | | --- | --- | | name |The name of the type to create.
| | definition |The definition of the fields for the type.
| ### baseDb.dropType(name) ⇒Drop (delete) a user-defined type (UDT) by name.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the dropType command.
| Param | Description | | --- | --- | | name |The name of the type to drop.
| ### baseDb.alterType(name, update) ⇒Alter a user-defined type (UDT) by renaming or adding fields.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the alterType command.
| Param | Description | | --- | --- | | name |The name of the type to alter.
| | update |The alterations to be made: renaming or adding fields.
| ### baseDb.syncTypes(types) ⇒Synchronizes the set of user-defined types (UDTs) in the database. It makes existing types in the database
match the list provided by types. New types that are missing are created, and types that exist in the database
but are not in the input list are dropped. If a type is present in both, we add all the new type's fields to the existing type.
BaseDb](#BaseDb)
**Returns**: An object describing which types were created, updated, or dropped.
**Throws**: - [AstraMongooseError](#AstraMongooseError) If an error occurs during type synchronization, with partial progress information in the error.
| Param | Description | | --- | --- | | types |An array of objects each specifying the name and CreateTypeDefinition for a UDT to synchronize.
| ### baseDb.command(command)Execute a command against the database.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| command | The command to be executed.
| ## CollectionsDb **Kind**: global class * [CollectionsDb](#CollectionsDb) * [new CollectionsDb(astraDb, keyspaceName)](#new_CollectionsDb_new) * [.collection(name)](#CollectionsDb+collection) * [.createCollection()](#CollectionsDb+createCollection) ### new CollectionsDb(astraDb, keyspaceName)Creates an instance of CollectionsDb. Do not instantiate this class directly.
| Param | Description | | --- | --- | | astraDb |The AstraDb instance to interact with the database.
| | keyspaceName |The name of the keyspace to use.
| ### collectionsDb.collection(name)Get a collection by name.
**Kind**: instance method of [CollectionsDb](#CollectionsDb)
| Param | Description |
| --- | --- |
| name | The name of the collection.
| ### collectionsDb.createCollection()Send a CreateCollection command to Data API.
**Kind**: instance method of [CollectionsDb](#CollectionsDb)
## TablesDb
**Kind**: global class
* [TablesDb](#TablesDb)
* [new TablesDb(astraDb, keyspaceName)](#new_TablesDb_new)
* [.collection(name)](#TablesDb+collection)
* [.createCollection()](#TablesDb+createCollection)
### new TablesDb(astraDb, keyspaceName)
Creates an instance of TablesDb. Do not instantiate this class directly.
| Param | Description | | --- | --- | | astraDb |The AstraDb instance to interact with the database.
| | keyspaceName |The name of the keyspace to use.
| ### tablesDb.collection(name)Get a table by name. This method is called collection() for compatibility with Mongoose, which calls
this method for getting a Mongoose Collection instance, which may map to a table in Astra DB when using tables mode.
TablesDb](#TablesDb)
| Param | Description |
| --- | --- |
| name | The name of the table.
| ### tablesDb.createCollection()Throws an error, astra-mongoose does not support creating collections in tables mode.
**Kind**: instance method of [TablesDb](#TablesDb)
## MongooseSet
MongooseSet is a Mongoose-specific wrapper around vanilla JavaScript sets
that represents a Cassandra set. It wraps a JavaScript Set and integrates with
Mongoose change tracking.
Takes 2 generic types: RawType and HydratedType. The RawType is the type of the value
stored in the database, while the HydratedType is the type of the value when it is
retrieved from the database - these are the same type for primitive types, but
are different for Mongoose subdocuments.
Add and delete operations use atomic updates ($push, $pullAll) when possible,
and only fall back to a full overwrite ($set) when there is a mixed sequence of operations.
Get atomics for Mongoose change tracking. Keep in mind Data API does not support multiple operations on the same set in the same operation, so we only support one atomic at a time.
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.clearAtomics()
Clear atomics for Mongoose change tracking. Called by Mongoose after the document is successfully saved.
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.\_markModified()
Internal method to mark the parent document as modified when the set changes
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.add()
Adds a value to the set and marks the parent document as modified
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.toBSON()
Converts the set into what will be sent on the wire
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.delete()
Deletes a value from the set and marks the parent document as modified
**Kind**: instance method of [MongooseSet](#MongooseSet)
### mongooseSet.clear()
Clears all values from the set and marks the parent document as modified
**Kind**: instance method of [MongooseSet](#MongooseSet)
## SchemaSet
SchemaSet is a custom Mongoose SchemaType that allows you to use Cassandra sets in tables mode.
A Set path translates to type: 'set' in the Data API.
Create a new instance of the Set SchemaType.
| Param | Description | | --- | --- | | key |the path to this set field in your schema
| | options |set options that define the type of values in the set
| ### schemaSet.getEmbeddedSchemaType()Get the embedded schema type for values in this set
**Kind**: instance method of [SchemaSet](#SchemaSet)
### schemaSet.cast()
Cast a given value to a MongooseSet with proper change tracking
**Kind**: instance method of [SchemaSet](#SchemaSet)
### schemaSet.\_castNullish()
Mongoose calls this function to cast when the value is nullish
**Kind**: instance method of [SchemaSet](#SchemaSet)
### schemaSet.castForQuery()
Required for Mongoose to properly handle this schema type
**Kind**: instance method of [SchemaSet](#SchemaSet)
## Vectorize
Vectorize is a custom Mongoose SchemaType that allows you set a vector value to a string for tables mode vectorize API. A Vectorize path is an array of numbers that can also be set to a string.
**Kind**: global class * [Vectorize](#Vectorize) * [new Vectorize(key, options)](#new_Vectorize_new) * [.cast()](#Vectorize+cast) * [.clone()](#Vectorize+clone) ### new Vectorize(key, options)Create a new instance of the Vectorize SchemaType. You may need to instantiate this type to add to your Mongoose
schema using Schema.prototype.path() for better TypeScript support.
the path to this vectorize field in your schema
| | options |vectorize options that define how to interact with the vectorize service, including the dimension
| ### vectorize.cast()Cast a given value to the appropriate type. Defers to the default casting behavior for Mongoose number arrays, with the one exception being strings.
**Kind**: instance method of [Vectorize](#Vectorize)
### vectorize.clone()
Overwritten to account for Mongoose SchemaArray constructor taking different arguments than Vectorize
**Kind**: instance method of [Vectorize](#Vectorize)
## AstraMongooseError
Base class for astra-mongoose-specific errors.
**Kind**: global class ## BaseDb ⇐ [BaseDb](#BaseDb)
Db instance that creates and manages collections.
**Kind**: global variable **Extends**: [BaseDb](#BaseDb)
* [BaseDb](#BaseDb) ⇐ [BaseDb](#BaseDb)
* [new BaseDb()](#new_BaseDb_new)
* [.createTable(name, definition)](#BaseDb+createTable)
* [.dropCollection(name)](#BaseDb+dropCollection)
* [.dropTable(name)](#BaseDb+dropTable)
* [.listCollections(options)](#BaseDb+listCollections)
* [.listTables()](#BaseDb+listTables)
* [.listTypes()](#BaseDb+listTypes) ⇒
* [.createType(name, definition)](#BaseDb+createType) ⇒
* [.dropType(name)](#BaseDb+dropType) ⇒
* [.alterType(name, update)](#BaseDb+alterType) ⇒
* [.syncTypes(types)](#BaseDb+syncTypes) ⇒
* [.command(command)](#BaseDb+command)
### new BaseDb()
Whether we're using "tables mode" or "collections mode". If tables mode, then collection() returns
a Table instance, not a Collection instance. Also, if tables mode, createCollection() throws an
error for Mongoose syncIndexes() compatibility reasons.
Create a new table with the specified name and definition
**Kind**: instance method of [BaseDb](#BaseDb)
| Param |
| --- |
| name |
| definition |
### baseDb.dropCollection(name)
Drop a collection by name.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| name | The name of the collection to be dropped.
| ### baseDb.dropTable(name)Drop a table by name. This function does not throw an error if the table does not exist.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param |
| --- |
| name |
### baseDb.listCollections(options)
List all collections in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| options | Additional options for listing collections.
| ### baseDb.listTables()List all tables in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
### baseDb.listTypes() ⇒
List all user-defined types (UDTs) in the database.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: An array of type descriptors.
### baseDb.createType(name, definition) ⇒Create a new user-defined type (UDT) with the specified name and fields definition.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the createType command.
| Param | Description | | --- | --- | | name |The name of the type to create.
| | definition |The definition of the fields for the type.
| ### baseDb.dropType(name) ⇒Drop (delete) a user-defined type (UDT) by name.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the dropType command.
| Param | Description | | --- | --- | | name |The name of the type to drop.
| ### baseDb.alterType(name, update) ⇒Alter a user-defined type (UDT) by renaming or adding fields.
**Kind**: instance method of [BaseDb](#BaseDb)
**Returns**: The result of the alterType command.
| Param | Description | | --- | --- | | name |The name of the type to alter.
| | update |The alterations to be made: renaming or adding fields.
| ### baseDb.syncTypes(types) ⇒Synchronizes the set of user-defined types (UDTs) in the database. It makes existing types in the database
match the list provided by types. New types that are missing are created, and types that exist in the database
but are not in the input list are dropped. If a type is present in both, we add all the new type's fields to the existing type.
BaseDb](#BaseDb)
**Returns**: An object describing which types were created, updated, or dropped.
**Throws**: - [AstraMongooseError](#AstraMongooseError) If an error occurs during type synchronization, with partial progress information in the error.
| Param | Description | | --- | --- | | types |An array of objects each specifying the name and CreateTypeDefinition for a UDT to synchronize.
| ### baseDb.command(command)Execute a command against the database.
**Kind**: instance method of [BaseDb](#BaseDb)
| Param | Description |
| --- | --- |
| command | The command to be executed.
| ## CollectionsDb ⇐ [BaseDb](#BaseDb)
Db instance that creates and manages tables.
**Kind**: global variable **Extends**: [BaseDb](#BaseDb)
* [CollectionsDb](#CollectionsDb) ⇐ [BaseDb](#BaseDb)
* [new CollectionsDb(astraDb, keyspaceName)](#new_CollectionsDb_new)
* [.collection(name)](#CollectionsDb+collection)
* [.createCollection()](#CollectionsDb+createCollection)
### new CollectionsDb(astraDb, keyspaceName)
Creates an instance of CollectionsDb. Do not instantiate this class directly.
| Param | Description | | --- | --- | | astraDb |The AstraDb instance to interact with the database.
| | keyspaceName |The name of the keyspace to use.
| ### collectionsDb.collection(name)Get a collection by name.
**Kind**: instance method of [CollectionsDb](#CollectionsDb)
| Param | Description |
| --- | --- |
| name | The name of the collection.
| ### collectionsDb.createCollection()Send a CreateCollection command to Data API.
**Kind**: instance method of [CollectionsDb](#CollectionsDb)
## handleVectorFieldsProjection()
Mongoose plugin to handle adding $vector to the projection by default if $vector has select: true.
Because $vector is deselected by default, this plugin makes it possible for the user to include $vector
by default from their schema.
You do not need to call this function directly. Mongoose applies this plugin automatically when you call setDriver().
Mongoose plugin to validate arrays of numbers that have a dimension property. Ensure that the array
is either nullish or has a length equal to the dimension.
You do not need to call this function directly. Mongoose applies this plugin automatically when you call setDriver().
Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()
Given a Mongoose schema, get the definitions of all the UDTs used by this schema. Used to create all UDTs required by the schema before creating the table.
**Kind**: global function ## convertSchemaToColumns()Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()
Create an Astra connection URI while connecting to Astra Data API.
**Kind**: global function ## tableDefinitionFromSchema()Given a Mongoose schema, create an equivalent Data API table definition for use with createTable()