# seal-odata-mongo

> seal-odata-mongo is a middleware that translates OData to MongoDB queries.

Latest version **0.0.8** (published 2017-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install seal-odata-mongo
pnpm add seal-odata-mongo
yarn add seal-odata-mongo
bun add seal-odata-mongo
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2017-02-09 |
| First published | 2017-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| Author | SEAL Systems AG |
| Maintainers | manni19682 |

## Links

- npm: https://www.npmjs.com/package/seal-odata-mongo
- Repository: https://github.com/sealsystems/seal-odata-mongo
- Homepage: https://github.com/sealsystems/seal-odata-mongo#readme
- Issues: https://github.com/sealsystems/seal-odata-mongo/issues
- npm.io page: https://npm.io/package/seal-odata-mongo

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) 4.17.4
- [comparejs](https://npm.io/package/comparejs.md) 0.1.5
- [breeze-mongodb](https://npm.io/package/breeze-mongodb.md) 0.0.8

## Recent versions

- 0.0.8 (latest) — 2017-02-09

## README

# seal-odata-mongo

[![CircleCI](https://circleci.com/gh/sealsystems/seal-odata-mongo.svg?style=svg)](https://circleci.com/gh/sealsystems/seal-odata-mongo)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/h2bha85i9rvpedao?svg=true)](https://ci.appveyor.com/project/Plossys/seal-odata-mongo)

seal-odata-mongo is a middleware that translates [OData](http://www.odata.org/) to MongoDB queries. [OData Version 2.0](http://www.odata.org/documentation/odata-version-2-0/uri-conventions/) URI conventions are supported.

## Installation

```bash
$ npm install seal-odata-mongo
```

## Quick start

First you need to add a reference to seal-odata-mongo within your application.

```javascript
const odataMongo = require('seal-odata-mongo');
```

Then you can enable Express routes to handle incoming OData queries. For that, add the middleware to the appropriate route. Within the route you then can access the `req.mongo.query` and `req.mongo.queryOptions` objects that contain the query and the query options for MongoDB.

```javascript
app.get('/data', odataMongo(), (req, res) => {
  db.collection('...').find(req.mongo.query, req.mongo.queryOptions).toArray((err, docs) => {
    // ...
  });
});
```

In case the client sends an invalid OData expression, the middleware responds with a `400` status code.

### supported OData keys

* `$filter`
* `$top` - limit the result to N elements
* `$skip` - skip N elements of the query
* `$select`
* `$inlinecount` - see implementation example in seal-rest to retrieve count and the result
* `$orderby`

## Running the build

To build this module use [roboter](https://www.npmjs.com/package/roboter).

```bash
$ bot
```

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