# hquery-store

> A utility for validating fields in a request against a specified table schema.

Latest version **1.0.13** (published 2023-12-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install hquery-store
pnpm add hquery-store
yarn add hquery-store
bun add hquery-store
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2023-12-14 |
| First published | 2023-12-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Himanshu Chauhan |
| Maintainers | himanshu_chauhan18 |
| Keywords | validation, utility, npm-package, validating and optimizing queries,  optimizing the query by sorting columns based on the specified schema order |

## Links

- npm: https://www.npmjs.com/package/hquery-store
- npm.io page: https://npm.io/package/hquery-store

## Dependencies (1)

- [string-similarity](https://npm.io/package/string-similarity.md) ^4.0.4

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.13 (latest) — 2023-12-14
- 1.0.12 — 2023-12-14
- 1.0.11 — 2023-12-11
- 1.0.10 — 2023-12-11
- 1.0.9 — 2023-12-11
- 1.0.8 — 2023-12-11
- 1.0.7 — 2023-12-11

## README

# Hquery-store

Hquery Store is a utility module designed to assist in validating and optimizing queries for a given schema. This module is particularly useful when working with database queries, ensuring that the requested fields are valid and optimizing the query by sorting columns based on the specified schema order.

## Author

- **Himanshu Chauhan**

# Function 

ValidateFields(request, TableName, excludeKeys = [])

This function validates the fields in the request against the provided schema (TableName). It returns an object containing the status and columns if successful, or an error object if validation fails.

request: The request object containing the fields to be validated.
TableName: The schema object representing the table structure.
excludeKeys: An optional array of keys to exclude from validation.

## Usage

```javascript


1. **Installation:**

   Install Hquery-store using npm:

   ``` npm install hquery-store --save```

### AdonisTs Integration

import {ValidateFields} from 'hquery-store/Hquery'

// Define your schema, e.g., EmployeeMaster
const EmployeeMaster = {
  tableName: 'EmployeeMaster', // required field
  id: 'Id',
  fname: 'FirstName',
  lname: 'LastName',
  email: 'CompanyEmail',
  activeSts: 'Is_Delete',
  password: 'Password',
  orgid: 'OrganizationId',
  desc: 'Description'
};

// Example route using Hquery Store
Route.post('/optimize', async ({ request, response }) => {
  const selectedColumns = ValidateFields(request, EmployeeMaster);

  if (!selectedColumns['status']) {
    return selectedColumns;
  }

  let query = `SELECT ${selectedColumns['columns']} FROM EmployeeMaster WHERE Id = ${request.body().id}`;
  return response.json(query);
});

---
_Source: https://npm.io/package/hquery-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
