@cuboapp/database 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuboapp/database",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Database methods",
5
5
  "main": "src/index.ts",
6
6
  "repository": "git@cuboapp.gitlab.yandexcloud.net:cubo/database.git",
package/src/db/index.ts CHANGED
@@ -10,7 +10,10 @@ export * from './utils'
10
10
  export class Database {
11
11
  public connection: Sequelize
12
12
 
13
- constructor(private connectOptions: Options, private otherOptions?: DatabaseOptions) {}
13
+ constructor(
14
+ private connectOptions: Options,
15
+ private otherOptions?: DatabaseOptions
16
+ ) {}
14
17
 
15
18
  public async connect() {
16
19
  const opts: Options = {
@@ -154,7 +157,7 @@ export class Database {
154
157
 
155
158
  return res[0].map((r) => (!!pkKey ? (pkType === 'number' ? +r[pkKey] : r[pkKey]) : r)) as T[]
156
159
  case 'mysql':
157
- return res as T[]
160
+ return result as unknown as T[]
158
161
  }
159
162
  }
160
163
  }
package/src/db/utils.ts CHANGED
@@ -24,7 +24,7 @@ export function dbPrepareUpdateQueryString(obj: Record<string, any>, prefix = ''
24
24
  if (Buffer.isBuffer(value)) {
25
25
  val = literal(value.toString('utf-8'))
26
26
  } else {
27
- if (value?.constructor?.name === 'Literal') {
27
+ if (['Literal', 'Date'].includes(value?.constructor?.name)) {
28
28
  val = value
29
29
  } else {
30
30
  val = value ? JSON.stringify(value) : null
@@ -61,7 +61,7 @@ export function dbPrepareInsertQueryString(obj: Record<string, any>, prefix = ''
61
61
  if (Buffer.isBuffer(value)) {
62
62
  val = literal(value.toString('utf-8'))
63
63
  } else {
64
- if (value?.constructor?.name === 'Literal') {
64
+ if (['Literal', 'Date'].includes(value?.constructor?.name)) {
65
65
  val = value
66
66
  } else {
67
67
  val = value ? JSON.stringify(value) : null