We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to build partial query while working with jsonb, but its printing string in inserted row:
exports.updateEntityLastCount = async ({ pairs, tournamentId }) => { const keys = Object.keys(pairs); const vals = Object.values(pairs).map( (value, index) => ((entity_last_count ->> ${keys[index]})::int + ${value})::text, ); const keyArray = sql${keys.join(", ")}; const valArray = sql${vals.join(", ")};
((entity_last_count ->> ${keys[index]})::int + ${value})::text
${keys.join(", ")}
${vals.join(", ")}
return sql UPDATE tournaments SET entity_last_count = entity_last_count || jsonb_object( ARRAY[${keyArray}], ARRAY[${valArray}]) WHERE id = ${tournamentId};; };
UPDATE tournaments SET entity_last_count = entity_last_count || jsonb_object( ARRAY[${keyArray}], ARRAY[${valArray}]) WHERE id = ${tournamentId};
DB inserted row: {"group": 1, "match": 1, "phase": "((entity_last_count ->> phase)::int + 1)::text", "bracket": 1}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Trying to build partial query while working with jsonb, but its printing string in inserted row:
exports.updateEntityLastCount = async ({ pairs, tournamentId }) => {
const keys = Object.keys(pairs);
const vals = Object.values(pairs).map(
(value, index) =>
((entity_last_count ->> ${keys[index]})::int + ${value})::text
,);
const keyArray = sql
${keys.join(", ")}
;const valArray = sql
${vals.join(", ")}
;return sql
UPDATE tournaments SET entity_last_count = entity_last_count || jsonb_object( ARRAY[${keyArray}], ARRAY[${valArray}]) WHERE id = ${tournamentId};
;};
DB inserted row:
{"group": 1, "match": 1, "phase": "((entity_last_count ->> phase)::int + 1)::text", "bracket": 1}
The text was updated successfully, but these errors were encountered: