# mongo-common-function

> First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.org/downloads). Then:

Latest version **1.0.7** (published 2023-03-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongo-common-function
pnpm add mongo-common-function
yarn add mongo-common-function
bun add mongo-common-function
```

## 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.7 |
| Published | 2023-03-02 |
| First published | 2023-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ritikparikh |
| Keywords | mongoose, pagination, mongodb, mongo, mongo db pagination, facet, plugin, paginate, paging, prev, nextpage, paginator, helper, mongo-common-function, agregation, table, datatable |

## Links

- npm: https://www.npmjs.com/package/mongo-common-function
- npm.io page: https://npm.io/package/mongo-common-function

## 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
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.7 (latest) — 2023-03-02
- 1.0.5 — 2023-03-02
- 1.0.6 — 2023-03-02
- 1.0.4 — 2023-03-02
- 1.0.3 — 2023-03-02
- 1.0.2 — 2023-03-02
- 1.0.1 — 2023-03-02
- 1.0.0 — 2023-03-02

## README

# Mongo Query some common function

## Installation

First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.org/downloads). Then:

```sh
$ npm install mongo-common-function
```
## Importing

```javascript
// Using Node.js `require()`
const mongoFunctions = require('mongo-common-function');

// Using ES6 imports
import mongoFunctions from 'mongo-common-function';
```
## Function Docs

- [paginationPipeBuilder]
- [freeTextSearch]
- [sortStage]

####  paginationPipeBuilder
Add after the last Aggragtion Pipeline to get Pagination in the mongodb or mongoose aggregation

**aggPipe:** _Existing Pipeline of your code._
**limit:** Page shown the rows. Limit as null condsider as all data will came on first page.
**page:** Page Number start with 1.

```javascript
// Using Node.js `require()`
//paginationPipeBuilder(aggPipe, limit, page);
const { paginationPipeBuilder } = require('mongo-common-function');

// Dummy input
paginationPipeBuilder({$match:{$eq:/**/}}, 5, 1);

//Dummy output
{ 
    pipeline: {
        "data": [],
        "data_info": {
            "totalCount": 0,
            "page": {
                "size": 0,
                "index": 1,
                "lastPage": true
            },
            "totalPage": 0
        }
    }, 
    staticPaging: {
            "data": [],
            "data_info": {
                "totalCount": 0,
                "page": {
                    "size": 0,
                    "index": 1,
                    "lastPage": true
                },
                "totalPage": 0
            }
        } 
    }
    
```

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