Skip to content

Commit 520a175

Browse files
committed
feat: Add 'uuid' column type to generate ids at import time
1 parent f38789d commit 520a175

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/Transformer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const csvStringify = require('csv-string').stringify
44
const hashFunction = require('./hash-function')
5+
const uuidFunction = require('./uuid-function')
56

67
class Transformer {
78
constructor (fileConfig) {
@@ -19,6 +20,9 @@ class Transformer {
1920
case 'hash':
2021
_this.columnFunctions.push(hashFunction)
2122
break
23+
case 'uuid':
24+
_this.columnFunctions.push(uuidFunction)
25+
break
2226
default:
2327
console.error('ERROR: Unknown outputColumnType ' + outputColumnType)
2428
}

lib/uuid-function.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const uuidV4 = require('uuid/v4');
2+
3+
module.exports = function uuidFunction () {
4+
return uuidV4()
5+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"lodash": "4.17.10",
3333
"make-dir": "1.3.0",
3434
"pump": "3.0.0",
35-
"upath": "1.1.0"
35+
"upath": "1.1.0",
36+
"uuid": "^3.3.2"
3637
},
3738
"devDependencies": {
3839
"chai": "4.1.2",

0 commit comments

Comments
 (0)