Skip to content

Commit d34c4e4

Browse files
authored
Merge pull request #18 from siaeyy/16-transformation-is-missing-sirutilsdriver-scylla
Non-cache query and UUID transformation (Issue #16)
2 parents 9a47f66 + 15ad342 commit d34c4e4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/driver-scylla/src/utils/driver.ts

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const driverActions = createActions(
3434
true
3535
)
3636

37+
result.rows.map(row => context.api.transformResponse(row))
38+
3739
return result.rows as T[]
3840
})
3941
}

packages/driver-scylla/src/utils/plugin.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pkg from '../../package.json'
22

33
import { createPlugin, getCircularReplacer, group } from '@sirutils/core'
4-
import { isRawObject, traverse, safeEjsonParse, safeEjsonStringify } from '@sirutils/safe-toolbox'
4+
import { isRawObject, safeEjsonParse, safeEjsonStringify, traverse } from '@sirutils/safe-toolbox'
55
import { createAdapter } from '@sirutils/seql'
66
import { Client, types } from 'cassandra-driver'
77

@@ -43,7 +43,7 @@ export const createScyllaDriver = createPlugin<
4343
const ejsonStr = safeEjsonStringify(data)
4444

4545
// Transform raw object to string if it can be
46-
if(ejsonStr.isOk()) {
46+
if (ejsonStr.isOk()) {
4747
return ejsonStr.value as T
4848
}
4949
}
@@ -54,14 +54,16 @@ export const createScyllaDriver = createPlugin<
5454
traverse(data).forEach(function (value) {
5555
if (value instanceof types.Integer) {
5656
this.update(+value)
57-
}else if (typeof value === "string") {
57+
} else if (typeof value === 'string') {
5858
// If field value's type is string and it's format is matched with ejson,
5959
// transform to object
6060
const ejsonData = safeEjsonParse(value)
6161

6262
if (ejsonData.isOk()) {
6363
this.update(ejsonData.value)
6464
}
65+
} else if (value instanceof types.Uuid) {
66+
this.update(value.toString())
6567
}
6668
})
6769
return data

0 commit comments

Comments
 (0)