# wc-query

> convert req.query to mongo find options

Latest version **0.0.15** (published 2016-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install wc-query
pnpm add wc-query
yarn add wc-query
bun add wc-query
```

## 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.15 |
| Published | 2016-02-06 |
| First published | 2014-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alex Suslov |
| Maintainers | alexsuslov |
| Keywords | express, generator-angular-fullstack, rest, mongodb, api |

## Links

- npm: https://www.npmjs.com/package/wc-query
- Repository: https://github.com/alexsuslov/wcQuery
- Homepage: https://github.com/alexsuslov/wcQuery#readme
- Issues: https://github.com/alexsuslov/wcQuery/issues
- npm.io page: https://npm.io/package/wc-query

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 0.0.15 (latest) — 2016-02-06
- 0.0.14 — 2015-06-19
- 0.0.13 — 2014-12-09
- 0.0.12 — 2014-07-28
- 0.0.11 — 2014-07-28
- 0.0.10 — 2014-07-27
- 0.0.9 — 2014-07-27
- 0.0.7 — 2014-07-21
- 0.0.6 — 2014-07-17
- 0.0.5 — 2014-07-17
- 0.0.4 — 2014-07-17
- 0.0.3 — 2014-07-16
- 0.0.2 — 2014-07-16
- 0.0.1 — 2014-07-16

## README

# Express req.query -> Mongoose model find options
## New in 0.0.15
remove deps
## 0.0.14
Rewrite from scratch

### Depricated:
- ObjectId

### Add new command:
```
Query.on '_', (name, value)->

```
function must return object for mongo

### Remove  command:
```
Query.off '_'

```



## New in 0.0.10
### ObjectId
- url: /api/item?name=_53c699da9189110000454007
    + name: ObjectId(53c699da9189110000454007)


## Simple use in server api controller:

```
"use strict"

_ = require("lodash")
Item = require("./item.model")
Query = require("wc-query")
fields = {}

# Get list of items
exports.index = (req, res) ->
  query = Query(req.query)
  Item.find query.conditions, fields, query.options, (err, items) ->
    throw err if err
    return handleError(res, err)  if err
    res.json 200, items
```

## Logical Query Operators
### OR 
- /?or='name=3,test=!4'
    + { '$or': [ { name: '3' }, { test: $ne :4 } ] }

### AND 
- /?and='name=3,test=!4'
    + { '$and': [ { name: '3' }, { test: $ne :4 } ] }


## Comparison Query Operators

### EQ
- url: /api/item?name=test
    + name: 'test'

### Exists

- url: /api/item?name=%2B
    + name: $exists: true

- url: /api/item?name=-
    + name: $exists: false

### ObjectId
- url: /api/item?name=_53c699da9189110000454007
    + name: ObjectId(53c699da9189110000454007)

### NEQ
- url: /api/item?name=!test
    + name: $ne: 'test'

### GT
- url: /api/item?name=>1
    + name: $gt: 1

### GTE
- url: /api/item?name=]1
    + name: $gte: 1

### LT
- url: /api/item?name=<1
    + name: $lt: 1

### LTE
- url: /api/item?name=[1
    + name: $lte: 1

### IN 
- url: /api/item?name=@1|2|3
    + name: $in: ['1','2','3']

### NIN 
- url: /api/item?name=#1|2|3
    + name: $nin: ['1','2','3']

## Evaluation Query Operators
### REGEX 
- url: /api/item?name=~test
    + name: $regex: 'test'


## Sort

- /api/item?order=name
    + options.sort:{name:1}
- /api/item?order=-name
    + options.sort:{name:-1}

## Limit
- /api/item?limit=25&skip=0
    + options.sort:{skip:0,limit:25}

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