This module is meant exporting data as csv or xls
- Description:
This module is meant exporting data as csv or xls
- Source:
Members
(inner) EXPORT_REDACTIONS
- Description:
Credential fields stripped from privileged collections on export, mirroring the DB Viewer read paths so the same data cannot be obtained through export.
- Source:
Credential fields stripped from privileged collections on export, mirroring the DB Viewer read paths so the same data cannot be obtained through export.
Methods
(static) convertData(data, type) → {string}
- Description:
Convert json object to needed data type
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
array | data to convert |
type |
string | type to which to convert |
Returns:
converted data
- Type
- string
(static) fromData(data, options)
- Description:
Create export from provided data
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
string | array | data to format |
|||||||||||||||||||||||||
options |
object | options for the export Properties
|
(static) fromRequest(options)
- Description:
Export data from response of request
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the export Properties
|
(static) output(params, data, filename, type)
- Description:
Output data as response
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
params | params object |
data |
string | data to output |
filename |
string | name of the file to output to browser |
type |
string | type to be used in content type |
(static) redactExportDoc(collection, doc) → {object}
- Description:
Remove/mask credential fields from a document before it is written to an export
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
string | collection the document belongs to |
doc |
object | document to redact (mutated and returned) |
Returns:
the redacted document
- Type
- object
(static) redactsExportCollection(collection) → {boolean}
- Description:
Whether documents from the given collection require credential redaction on export
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
string | collection name |
Returns:
true if the collection is redacted on export
- Type
- boolean
(static) stream(params, stream, options)
- Description:
Stream data as response
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
params | params object |
stream |
Stream | cursor object. Need to call stream on it. |
options |
string | options object options.filename - name of the file to output to browser options.type - type to be used in content type options.projection - object of field projection options.mapper - object of mapping if need to transform data(for example timestamp to date string) |
(inner) findWriteStage(pipeline) → {string|null}
- Description:
Look for an aggregation stage that writes, at any nesting depth.
Sub-pipelines inside $lookup, $unionWith and $facet are searched too, so a write cannot be hidden one level down. Names are matched as object keys, which is the only place a stage operator appears.
The node budget is a stop on runaway work, not a verdict. Exhausting it means the pipeline could not be verified, which is a reason to refuse rather than to proceed: returning "nothing found" there would let a large enough structure in front of an $out carry the write through.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
pipeline |
Array | aggregation pipeline to inspect |
Returns:
why the pipeline must be refused, or null when it is safe
- Type
- string | null
(inner) flattenArray(arr) → {object}
- Description:
Flattens array of objects
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
arr |
array | array with objects to flatten |
Returns:
with property data for array with flattened objects and fields property for fields array
- Type
- object
(inner) flattenObject(ob, fields) → {object}
- Description:
Flattens nested object recursively
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
ob |
object | object to flatten |
fields |
object | object with fields to store unique ones |
Returns:
flattened object
- Type
- object
(inner) getValues(values, valuesMap, paramList, doc, options)
- Description:
function to collect calues in order based on current order.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
values |
array | arary to collect values |
valuesMap |
object | object to see which values are collected |
paramList |
array | array of keys(in order) |
doc |
object | data from db |
options |
object | {options.collectProp = true if collect properties,if false use only listed(from projection), options.mapper - mapper for fransforming data} |
(inner) isObjectId(id) → {boolean}
- Description:
Check if id is valid ObjectID
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | id to check |
Returns:
true if valid
- Type
- boolean
(inner) preventCSVInjection(val) → {varies}
- Description:
Escape values that can cause CSV injection
CSV only. flattenObject feeds the xls, xlsx and json paths as well, and those writers emit typed cells or JSON strings rather than anything a spreadsheet parses as a formula, so neutralizing there would put a marker into values that need none. This is called where CSV text is produced instead: processCSVvalue for the streamed writer, and convertData's csv branch for the buffered one.
Safe to apply twice - a value already carrying the marker is returned untouched - because a cell can reach it from a row and again from a serializer.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
val |
varies | value to escape |
Returns:
escaped value
- Type
- varies
(inner) processCSVvalue(value) → {string}
- Description:
Function to make all values CSV friendly
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | value to convert |
Returns:
- converted string
- Type
- string
(inner) transformValue(value, key, mapper, doc) → {string}
- Description:
Transform value
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
value |
object | any value |
key |
string | key |
mapper |
object | object with information how to transform data |
doc |
object | original document |
Returns:
transformed value
- Type
- string
(inner) transformValuesInObject(doc, mapper) → {object}
- Description:
Transform all values in object
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
doc |
object | any value |
mapper |
object | object with information how to transform data |
Returns:
object with transformed data
- Type
- object