Aller au contenu principal

Class: SimpleMongoReader

Read in from MongoDB

Implements

Constructors

constructor

new SimpleMongoReader(client)

Parameters

NameType
clientMongoClient

Defined in

packages/core/src/readers/SimpleMongoReader.ts:11

Properties

client

Private client: MongoClient

Defined in

packages/core/src/readers/SimpleMongoReader.ts:9

Methods

flatten

Private flatten(texts): string[]

Flattens an array of strings or string arrays into a single-dimensional array of strings.

Parameters

NameTypeDescription
texts(string | string[])[]The array of strings or string arrays to flatten.

Returns

string[]

The flattened array of strings.

Defined in

packages/core/src/readers/SimpleMongoReader.ts:20


loadData

loadData(dbName, collectionName, fieldNames?, separator?, filterQuery?, maxDocs?, metadataNames?): Promise<Document<Metadata>[]>

Loads data from MongoDB collection

Parameters

NameTypeDefault valueDescription
dbNamestringundefinedThe name of the database to load.
collectionNamestringundefinedThe name of the collection to load.
fieldNamesstring[]undefinedAn array of field names to retrieve from each document. Defaults to ["text"].
separatorstring""The separator to join multiple field values. Defaults to an empty string.
filterQueryRecord<string, any>{}Specific query, as specified by MongoDB NodeJS documentation.
maxDocsnumber0The maximum number of documents to retrieve. Defaults to 0 (retrieve all documents).
metadataNames?string[]undefinedAn optional array of metadata field names. If specified extracts this information as metadata.

Returns

Promise<Document<Metadata>[]>

Throws

If a field specified in fieldNames or metadataNames is not found in a MongoDB document.

Implementation of

BaseReader.loadData

Defined in

packages/core/src/readers/SimpleMongoReader.ts:39