# @tjc-group/odata-v2-mysql

> OData to MySQL query compiler (downgrade from odata-v4-mysql)

Latest version **0.1.21** (published 2021-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tjc-group/odata-v2-mysql
pnpm add @tjc-group/odata-v2-mysql
yarn add @tjc-group/odata-v2-mysql
bun add @tjc-group/odata-v2-mysql
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.21 |
| Published | 2021-07-19 |
| First published | 2020-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JayStack |
| Maintainers | skorolev-tjc |
| Keywords | OData, V4, sql |

## Links

- npm: https://www.npmjs.com/package/@tjc-group/odata-v2-mysql
- Repository: https://github.com/tjc-group/odata-v2-mysql
- Homepage: https://github.com/tjc-group/odata-v2-mysql#readme
- Issues: https://github.com/tjc-group/odata-v2-mysql/issues
- npm.io page: https://npm.io/package/@tjc-group/odata-v2-mysql

## Dependencies (2)

- [odata-v4-sql](https://npm.io/package/odata-v4-sql.md) ^0.1.2
- [@tjc-group/odata-v2-parser](https://npm.io/package/@tjc-group/odata-v2-parser.md) 0.0.19

## Recent versions

- 0.1.21 (latest) — 2021-07-19
- 0.1.20 — 2021-07-19
- 0.1.19 — 2021-05-10
- 0.1.18 — 2021-05-10
- 0.1.17 — 2020-09-14
- 0.1.16 — 2020-06-29
- 0.1.15 — 2020-06-11
- 0.1.14 — 2020-06-11
- 0.1.13 — 2020-06-11
- 0.1.12 — 2020-06-09
- 0.1.11 — 2020-05-24
- 0.1.10 — 2020-05-24
- 0.1.9 — 2020-05-21
- 0.1.8 — 2020-05-20
- 0.1.7 — 2020-05-20
- … 5 more at https://npm.io/package/@tjc-group/odata-v2-mysql/versions

## README

# OData V4 Service modules - MySQL Connector

Service OData v4 requests from a MySQL data store.

## Synopsis
The OData V4 MySQL Connector provides functionality to convert the various types of OData segments
into SQL query statements, that you can execute over a MySQL database.

## Potential usage scenarios

- Create high speed, standard compliant data sharing APIs

## Usage as server - TypeScript
```javascript
import { createFilter } from 'odata-v4-mysql'

//example request:  GET /api/Users?$filter=Id eq 42
app.get("/api/Users", (req: Request, res: Response) => {
    const filter = createFilter(req.query.$filter);
    // connection instance from mysql module
    connection.query(`SELECT * FROM Users WHERE ${filter.where}`, filter.parameters, function(err, data){
        res.json({
        	'@odata.context': req.protocol + '://' + req.get('host') + '/api/$metadata#Users',
        	value: data
        });
    });
});
```

Advanced TypeScript example available [here](https://raw.githubusercontent.com/jaystack/odata-v4-mysql/master/src/example/sql.ts).

## Usage ES5
```javascript
var createFilter = require('odata-v4-mysql').createFilter;

app.get("/api/Users", function(req, res) {
    var filter = createFilter(req.query.$filter);
    // connection instance from mysql module
    connection.query(filter.from("Users"), filter.parameters, function(err, data){
        res.json({
        	'@odata.context': req.protocol + '://' + req.get('host') + '/api/$metadata#Users',
        	value: data
        });
    });
})
```

## Supported OData segments

* $filter
* $select
* $skip
* $top
* $orderby
* $expand

---
_Source: https://npm.io/package/@tjc-group/odata-v2-mysql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
