sidorares / sidorares/node-mysql2

dynamic ordering of tables

Open
#949 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Hi,

I have admin panel in angular and every sub-menu has identical table component. I've set asc and desc icon to every th tag and I like to emit asc and desc values depending whch asc-desc icon next to th tag is clicked.

How I can implement this step in node.js when I send asc or desc and the name of the column dynamically as string?

const result = await mysql.select( myquery, ['columnA', 'desc'], );

The order in the sql query for now I've set as order by ? ?, but I can't make it work. I've tried also to wrap the input params withing escape or unescape function, but still not luck.

The query does not return error, but everytime input params force the query to sort asc, like it send the strings together with the single quotes.

BR, Igor

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file or test. Start by reproducing the shown mysql.select call with a dynamic column and direction, then inspect the query-parameter documentation; done would require a clear supported resolution or a documentation update.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js
Domain
database
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.