This module is meant exporting data as csv or xls
- Description:
This module is meant exporting data as csv or xls
- Source:
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) fromDatabase(options)
- Description:
Export data from database
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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) 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) 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
- 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