# Class VectorDBInstance

Base class for all SDK objects.

This class provides a base implementation for all SDK objects. It handles event emission, promise management, and initialization.

This object is used to ensure that an SRE instance is initialized, and if not, create one with default settings.

#### Hierarchy (View Summary)

- SDKObject
  - VectorDBInstance

- Defined in src/VectorDB/VectorDBInstance.class.ts:36

##### Index

### Constructors

constructor

### Properties

_readyPromise

### Accessors

ready

### Methods

deleteDoc
emit
init
initSignal
insertDoc
off
on
once
purge
removeListener
search
updateDoc

## Constructors

### constructor

- new VectorDBInstance(
  providerId: TVectorDBProvider,
  VectorDBSettings?: any,
  candidate?: AccessCandidate,
  ): VectorDBInstance

  #### Parameters

  - providerId: TVectorDBProvider
  - `Optional` VectorDBSettings: any
  - `Optional` candidate: AccessCandidate

  #### Returns VectorDBInstance

  Overrides SDKObject.constructor

  - Defined in src/VectorDB/VectorDBInstance.class.ts:42

## Properties

### `Protected`_readyPromise

_readyPromise: ControlledPromise<any>

Inherited from SDKObject._readyPromise

- Defined in src/Core/SDKObject.class.ts:17

## Accessors

### ready

- get ready(): ControlledPromise<any>

  #### Returns ControlledPromise<any>

  Inherited from SDKObject.ready

  - Defined in src/Core/SDKObject.class.ts:19

## Methods

### deleteDoc

- deleteDoc(name: string): Promise<boolean>

  Delete a document from the vector database

  #### Parameters

  - name: string

    The name of the document

  #### Returns Promise<boolean>

  true if the document was deleted, false otherwise

  #### Example

      const pineConeSettings = {/* ... pinecone settings ... */}
      const pinecone = VectorDB.Pinecone('my_namespace', pineConeSettings);
      const success = await pinecone.deleteDoc('test');

  - Defined in src/VectorDB/VectorDBInstance.class.ts:196

### emit

- emit(event: string, ...args: any[]): void

  #### Parameters

  - event: string
  - ...args: any[]

  #### Returns void

  Inherited from SDKObject.emit

  - Defined in src/Core/SDKObject.class.ts:45

### `Protected` init

- init(): Promise<void>

  #### Returns Promise<void>

  Overrides SDKObject.init

  - Defined in src/VectorDB/VectorDBInstance.class.ts:47

### `Protected` initSignal

- initSignal(): Promise<void>

  #### Returns Promise<void>

  Inherited from SDKObject.initSignal

  - Defined in src/Core/SDKObject.class.ts:37

### insertDoc

- insertDoc(
  name: string,
  data: string | TParsedDocument,
  options?: TInsertDocOptions,
  ): Promise<any>

  Insert a document into the vector database

  #### Parameters

  - name: string

    The name of the document

  - data: string | TParsedDocument

    The data to insert. Can be a string or a TParsedDocument

  - `Optional` options: TInsertDocOptions

  #### Returns Promise<any>

  #### Example

      const pineConeSettings = {/* ... pinecone settings ... */}
      const pinecone = VectorDB.Pinecone('my_namespace', pineConeSettings);
      const id = await pinecone.insertDoc('test', 'Hello, world!', { myEntry: 'My Metadata' });

  - Defined in src/VectorDB/VectorDBInstance.class.ts:105

### off

- off(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.off

  - Defined in src/Core/SDKObject.class.ts:49

### on

- on(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.on

  - Defined in src/Core/SDKObject.class.ts:41

### once

- once(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.once

  - Defined in src/Core/SDKObject.class.ts:53

### purge

- purge(): Promise<void>

  Purge the current namespace of the vector database

  Note : this will delete all the data in the current namespace.

  #### Returns Promise<void>

  void

  #### Example

      const pinecone = VectorDB.Pinecone('my_namespace', pineConeSettings);
      await pinecone.purge();

  - Defined in src/VectorDB/VectorDBInstance.class.ts:245

### removeListener

- removeListener(event: string, listener: (...args: any[]) => void): void

  #### Parameters

  - event: string
  - listener: (...args: any[]) => void

  #### Returns void

  Inherited from SDKObject.removeListener

  - Defined in src/Core/SDKObject.class.ts:56

### search

- search(
  query: string,
  options?: TVectorDBSearchOptions,
  ): Promise<{ embedding: any; metadata: any; text: any }[]>

  Search the vector database for a query

  #### Parameters

  - query: string

    The query to search for

  - `Optional` options: TVectorDBSearchOptions

    The options for the search

  #### Returns Promise<{ embedding: any; metadata: any; text: any }[]>

  The search results

  #### Example

      const pineConeSettings = {/* ... pinecone settings ... */}
      const pinecone = VectorDB.Pinecone('my_namespace', pineConeSettings);
      const results = await pinecone.search('Hello, world!');

  - Defined in src/VectorDB/VectorDBInstance.class.ts:218

### updateDoc

- updateDoc(
  name: string,
  data: string | TParsedDocument,
  options?: TInsertDocOptions,
  ): Promise<any>

  Update a document in the vector database.

  Note : this will index the new data on top of the existing data. if you want to replace the existing data, you should delete the document first (see deleteDoc)

  #### Parameters

  - name: string

    The name of the document

  - data: string | TParsedDocument

    The data to update. Can be a string or a TParsedDocument

  - `Optional` options: TInsertDocOptions

  #### Returns Promise<any>

  #### Example

      const pineConeSettings = {/* ... pinecone settings ... */}
      const pinecone = VectorDB.Pinecone('my_namespace', pineConeSettings);
      const id = await pinecone.updateDoc('test', 'Hello, world!', { myEntry: 'My Metadata' });

  - Defined in src/VectorDB/VectorDBInstance.class.ts:178