# dynamic_mongoose_searcher

> search in mongoose module using any property

Latest version **2.0.0** (published 2016-05-20) · 0 weekly downloads

## Install

```sh
npm install dynamic_mongoose_searcher
pnpm add dynamic_mongoose_searcher
yarn add dynamic_mongoose_searcher
bun add dynamic_mongoose_searcher
```

## 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 | 2.0.0 |
| Published | 2016-05-20 |
| First published | 2016-04-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | a.alghabban@geniusescode.net |
| Maintainers | geniusescode |

## Links

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

## Recent versions

- 2.0.0 (latest) — 2016-05-20
- 1.1.2 — 2016-04-20
- 1.1.1 — 2016-04-20
- 1.1.0 — 2016-04-20
- 1.0.0 — 2016-04-19
- 0.0.0 — 2016-04-19

## README

simplify create mongoose search query with dynamic searching properties and sorting options
by passing the searching terms in the http body request using express and body-parser 

## Installation

$ npm install dynamic_mongoose_searcher

$ Backend

```
var mongoose = require("mongoose");

var ads_collections = mongoose.model("ads");

var dynamic_mongoose_saerch = require("dynamic_mongoose_search");

exports.search = function (http_request, http_response) {
       var option = {
            'page_number': http_request.params.page_number,
            'limit': 20
        };

        dynamic_mongoose_saerch.create_query(http_request, ads_collections, option, function (error, query) {
            query.populate("city", "name _id");
            query.exec(function (finding_error, result) {
                return http_response.status(200).send(result);
            });
        });
};

```

$ FontEnd

```
   http_request body,  search one field

    {
       "city": "5709606579e756e8c1939c7d",  <-- filter using city.id
       
       "sort_options":[{  <--- if you want to sort result
        "sort_field":"create_date", 
        "sort_type": "-1"
        }] 
    }

    http_request body, search multi field with sorting

    {
       "city": "5709606579e756e8c1939c7d",  <-- filter using city.id
       "user": "5709606579e756e8c1939343",  <-- and the user id
       "sort_options":
        [{  
            "sort_field":"create_date", <--- if you want to sort result
            "sort_type": "-1"
        }] 
    }

   http_request body, search multi field without sorting

    {
       "city": "5709606579e756e8c1939c7d",  <-- filter using city.id
       "user": "5709606579e756e8c1939343"   <-- filter using user.id
    }

```

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