Skip to content

Commit f4e3987

Browse files
committed
Remove transforms
1 parent 56ce9f6 commit f4e3987

File tree

2 files changed

+3
-47
lines changed

2 files changed

+3
-47
lines changed

src/index.js

+1-22
Original file line numberDiff line numberDiff line change
@@ -1361,16 +1361,11 @@ module.exports = function (schemaName, schema, config) {
13611361
self
13621362
)
13631363
})
1364-
return config.transforms?.read
1365-
? recordset.map(config.transforms.read)
1366-
: recordset
1364+
return recordset
13671365
})
13681366
})
13691367
},
13701368
create: function (entity, options) {
1371-
if (config.transforms?.write) {
1372-
entity = config.transforms.write(entity)
1373-
}
13741369
options = options || {}
13751370
var self = this
13761371
var isInstance =
@@ -1422,17 +1417,11 @@ module.exports = function (schemaName, schema, config) {
14221417
entity,
14231418
self
14241419
)
1425-
if (config.transforms?.read) {
1426-
res = config.transforms.read(res)
1427-
}
14281420
return res
14291421
})
14301422
})
14311423
},
14321424
update: function (entity, key, options) {
1433-
if (config.transforms?.write) {
1434-
entity = config.transforms.write(entity)
1435-
}
14361425
var self = this
14371426
key = key || entity[data.primaryKeyAttributes[0]]
14381427
if (!key) {
@@ -1551,9 +1540,6 @@ module.exports = function (schemaName, schema, config) {
15511540
entity,
15521541
self
15531542
)
1554-
if (config.transforms?.read) {
1555-
res = config.transforms.read(res)
1556-
}
15571543
return res
15581544
})
15591545
})
@@ -1720,13 +1706,6 @@ module.exports = function (schemaName, schema, config) {
17201706
rebuild()
17211707
return data.public
17221708
},
1723-
setTransforms: function ({read, write}) {
1724-
config.transforms = {
1725-
read,
1726-
write
1727-
}
1728-
return data.public
1729-
},
17301709
setScope: function (scope) {
17311710
data.scope = scope
17321711
rebuild()

test/spec.js

+2-25
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ module.exports = function (options) {
108108
}
109109
})
110110
entityCadastro.setDialect(db.dialect)
111-
entityCadastro.setTransforms({
112-
read: record => {
113-
record.emails = ['hi_1@abc.com', 'hi_2@abc.com']
114-
return record
115-
},
116-
write: record => {
117-
record.EMAIL = record.emails?.[0]
118-
delete record.emails
119-
return record
120-
}
121-
})
122111
tableCadastro = entityCadastro.new(db)
123112
tableCadastro2 = entityCadastro.new(db2)
124113
tableCadastro
@@ -213,22 +202,14 @@ module.exports = function (options) {
213202
expect(record.id).to.not.equal(undefined)
214203
expect(record.updatedAt).to.not.equal(undefined)
215204
expect(end[1]).above(minNanoSecsToSave)
216-
expect(record.emails).to.deep.equal([
217-
'hi_1@abc.com',
218-
'hi_2@abc.com'
219-
])
220205
return tableCadastro2
221206
.update({...record, EMAIL: 'z@a.com'})
222207
.then(function (record) {
223208
end = process.hrtime(start)
224209
expect(record.id).to.not.equal(undefined)
225210
expect(record.updatedAt).to.not.equal(undefined)
226211
expect(end[1]).above(minNanoSecsToSave)
227-
expect(record.EMAIL).to.equal('hi_1@abc.com')
228-
expect(record.emails).to.deep.equal([
229-
'hi_1@abc.com',
230-
'hi_2@abc.com'
231-
])
212+
expect(record.EMAIL).to.equal('z@a.com')
232213
done()
233214
})
234215
})
@@ -244,11 +225,7 @@ module.exports = function (options) {
244225
expect(recordset.length).to.equal(1)
245226
expect(tableCadastro2.db).to.equal(db2)
246227
const record = recordset[0]
247-
expect(record.EMAIL).to.equal('hi_1@abc.com')
248-
expect(record.emails).to.deep.equal([
249-
'hi_1@abc.com',
250-
'hi_2@abc.com'
251-
])
228+
expect(record.EMAIL).to.equal('z@a.com')
252229
done()
253230
})
254231
.catch(function (err) {

0 commit comments

Comments
 (0)