api/parts/data/exports

This module is meant exporting data as csv or xls

Source:

Methods

(static) convertData(data, type) → {string}

Source:

Convert json object to needed data type

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)

Source:

Create export from provided data

Parameters:
Name Type Description
data string | array

data to format

options object

options for the export

Properties
Name Type Attributes Default Description
params params

params object

type string <optional>
json

type of data to output

filename string <optional>

name of the file to output, by default auto generated

output function

callback function where to pass data, by default outputs as file based on type

(static) fromDatabase(options)

Source:

Export data from database

Parameters:
Name Type Description
options object

options for the export

Properties
Name Type Attributes Default Description
db object

database connection

params params

params object

collection string

name of the collection to export

query object <optional>
{}

database query which data to filter

projection object <optional>
{}

database projections which fields to return

sort object <optional>
natural

sort object for cursor

limit number <optional>
10000

amount of items to output

skip number <optional>
0

amount of items to skip from start

type string <optional>
json

type of data to output

filename string <optional>

name of the file to output, by default auto generated

output function

callback function where to pass data, by default outputs as file based on type

(static) fromRequest(options)

Source:

Export data from response of request

Parameters:
Name Type Description
options object

options for the export

Properties
Name Type Attributes Default Description
params params

params object

path object

path for api endpoint

data object

json data to use as post or query string

prop object

which property to export, tries to export whole response if not provided

method object <optional>
POST

request method type

type string <optional>
json

type of data to output

filename string <optional>

name of the file to output, by default auto generated

output function

callback function where to pass data, by default outputs as file based on type

(static) output(params, data, filename, type)

Source:

Output data as response

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, filename, type, projection)

Source:

Stream data as response

Parameters:
Name Type Description
params params

params object

stream Stream

stream to output

filename string

name of the file to output to browser

type string

type to be used in content type

projection object

object of field projection

(inner) flattenArray(arr) → {object}

Source:

Flattens array of objects

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}

Source:

Flattens nested object recursively

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, collectProp)

Source:

function to collect calues in order based on current order.

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

collectProp boolean

true if collect properties,if false use only listed(from projection)

(inner) preventCSVInjection(val) → {varies}

Source:

Escape values that can cause CSV injection

Parameters:
Name Type Description
val varies

value to escape

Returns:

escaped value

Type
varies

(inner) processCSVvalue(value) → {string}

Source:

Function to make all values CSV friendly

Parameters:
Name Type Description
value string

value to convert

Returns:
  • converted string
Type
string