@qrvey/data-persistence
Advanced tools
Comparing version 0.3.8 to 0.3.9-beta-1
@@ -364,3 +364,2 @@ "use strict"; | ||
query += this.buildFilterClause(filters); | ||
console.log('query: ', query); | ||
return this.runQuery(query); | ||
@@ -433,2 +432,3 @@ } | ||
functionExpr: '', | ||
isDynamoFunction: true, | ||
}; | ||
@@ -455,8 +455,17 @@ if (columnType == 'array') { | ||
const columnName = arrayPath.shift(); | ||
const jsonbInsertExpressions = this.getExpressionsByDefinitionForJSONBInsert(columnName, params.value); | ||
const options = { | ||
isDynamoFunction: params === null || params === void 0 ? void 0 : params.isDynamoFunction, | ||
relativePath: arrayPath.length && Array.isArray(arrayPath) ? arrayPath : [], | ||
}; | ||
const jsonbInsertExpressions = this.getExpressionsByDefinitionForJSONBInsert(columnName, params.value, options); | ||
const expressions = this.buildJSONBExpression(jsonbInsertExpressions, 'jsonb_insert'); | ||
return expressions; | ||
} | ||
getExpressionsByDefinitionForJSONBInsert(columnName, value) { | ||
getExpressionsByDefinitionForJSONBInsert(columnName, value, options) { | ||
const jsonbInsertExpressions = []; | ||
let pathToAffect = '0'; | ||
if (options.isDynamoFunction == true) { | ||
options.relativePath.push('0'); | ||
pathToAffect = options.relativePath.join(','); | ||
} | ||
try { | ||
@@ -466,4 +475,8 @@ const parsedValue = JSON.parse(value); | ||
parsedValue.forEach((arrayValue) => { | ||
arrayValue = | ||
typeof arrayValue == 'string' | ||
? `"${arrayValue}"` | ||
: arrayValue; | ||
jsonbInsertExpressions.push({ | ||
jsonExpr: `'{0}','${this.serializeJSONValue(arrayValue)}'`, | ||
jsonExpr: `'{${pathToAffect}}','${this.serializeJSONValue(arrayValue)}'`, | ||
columnName: `"${columnName}"`, | ||
@@ -475,3 +488,3 @@ }); | ||
jsonbInsertExpressions.push({ | ||
jsonExpr: `'{0}','${this.serializeJSONValue(parsedValue)}'`, | ||
jsonExpr: `'{${pathToAffect}}','${this.serializeJSONValue(parsedValue)}'`, | ||
columnName: `"${columnName}"`, | ||
@@ -483,3 +496,3 @@ }); | ||
jsonbInsertExpressions.push({ | ||
jsonExpr: `'{0}','${value}'`, | ||
jsonExpr: `'{${pathToAffect}}','${value}'`, | ||
columnName: `"${columnName}"`, | ||
@@ -486,0 +499,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"main": "dist/cjs/index.js", | ||
"version": "0.3.8", | ||
"version": "0.3.9-beta-1", | ||
"license": "MIT", | ||
@@ -31,3 +31,3 @@ "exports": { | ||
"publish-package-dev": "yarn prepare-publish && yarn publish-codeartifact", | ||
"publish-package": "yarn prepare-publish && npm publish" | ||
"publish-package": "yarn prepare-publish && npm publish --tag beta" | ||
}, | ||
@@ -34,0 +34,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
366944
4070