Skip to content

Commit

Permalink
Remove lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
niklauslee committed May 24, 2018
1 parent 350abe9 commit a70756c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ddl-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

const fs = require('fs')
const _ = require('lodash')
const codegen = require('./codegen-utils')

/**
Expand Down Expand Up @@ -141,7 +140,7 @@ class DDLGenerator {
var matched = true
var matchedFKs = []
_pks.forEach(function (pk) {
var r = _.find(fks, function (k) { return k.referenceTo === pk })
var r = fks.find(function (k) { return k.referenceTo === pk })
if (r) {
matchedFKs.push(r)
} else {
Expand All @@ -150,12 +149,12 @@ class DDLGenerator {
})

if (matched) {
fks = _.difference(fks, matchedFKs)
fks = fks.filter(e => { return !matchedFKs.includes(e) })
var line = 'ALTER TABLE '
line += self.getId(elem.name, options) + ' '
line += 'ADD FOREIGN KEY (' + _.map(matchedFKs, function (k) { return self.getId(k.name, options) }).join(', ') + ') '
line += 'ADD FOREIGN KEY (' + matchedFKs.map(function (k) { return self.getId(k.name, options) }).join(', ') + ') '
line += 'REFERENCES ' + self.getId(_pks[0]._parent.name, options)
line += '(' + _.map(_pks, function (k) { return self.getId(k.name, options) }) + ');'
line += '(' + _pks.map(function (k) { return self.getId(k.name, options) }) + ');'
codeWriter.writeLine(line)
}
}
Expand Down

0 comments on commit a70756c

Please sign in to comment.