-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomFunctions.js
65 lines (58 loc) · 1.46 KB
/
customFunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Custom constants
*/
const allowedTypes = ['populatedPlace', 'other'];
const allowedLocalTypes = ['Postcode', 'Hamlet'];
/**
* Example of how to import data,
* in addition to the packages defaults of
* ['id', 'name', 'type', 'lat', 'lng']
*/
const customFunctions = {
/**
* Check if the row is valid.
* By default only postcodes are valid.
*/
rowIsValidFilter: async ({ rowIsValid, data }) => {
return {
rowIsValid:
allowedTypes.includes(data['TYPE']) &&
allowedLocalTypes.includes(data['LOCAL_TYPE']),
};
},
/**
* Add to the dist (processed) csv file header
*/
distCsvHeadersFilter: async ({ distCsvHeaders }) => {
await distCsvHeaders.push('county');
return { distCsvHeaders };
},
/**
* If county is on the row, then set it to the
* processedRow object
*/
processedRowFilter: async ({ processedRow, row }) => {
processedRow.county = row.COUNTY_UNITARY !== '' ? row.COUNTY_UNITARY : null;
return { processedRow };
},
/**
* Add the the cypher import statement
*/
placeImportStatementFilter: async ({ placeImportStatement }) => {
const find = `// PLACE PROPERTIES`;
const replace = `
${find}
p.county = place.county,
`;
return {
placeImportStatement: placeImportStatement.replace(find, replace),
};
},
/**
* Add your own debugger here.
*/
// debug: (message) => {
// console.debug(message);
// },
};
export { customFunctions };