Class: SimpleMongoReader
Read in from MongoDB
Implements
Constructors
constructor
• new SimpleMongoReader(client
): SimpleMongoReader
Parameters
Name | Type |
---|---|
client | MongoClient |
Returns
Defined in
packages/core/src/readers/SimpleMongoReader.ts:12
Properties
client
• Private
client: MongoClient
Defined in
packages/core/src/readers/SimpleMongoReader.ts:10
Methods
flatten
▸ flatten(texts
): string
[]
Flattens an array of strings or string arrays into a single-dimensional array of strings.
Parameters
Name | Type | Description |
---|---|---|
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:21
loadData
▸ loadData(dbName
, collectionName
, fieldNames?
, separator?
, filterQuery?
, maxDocs?
, metadataNames?
): Promise
<Document
<Metadata
>[]>
Loads data from MongoDB collection
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dbName | string | undefined | The name of the database to load. |
collectionName | string | undefined | The name of the collection to load. |
fieldNames | string [] | undefined | An array of field names to retrieve from each document. Defaults to ["text"]. |
separator | string | "" | The separator to join multiple field values. Defaults to an empty string. |
filterQuery | Record <string , any > | {} | Specific query, as specified by MongoDB NodeJS documentation. |
maxDocs | number | 0 | The maximum number of documents to retrieve. Defaults to 0 (retrieve all documents). |
metadataNames? | string [] | undefined | An optional array of metadata field names. If specified extracts this information as metadata. |
Returns
Throws
If a field specified in fieldNames or metadataNames is not found in a MongoDB document.