# mongo-tail-queries

> Tail all the mongo queries

Latest version **1.0.2** (published 2018-12-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongo-tail-queries
pnpm add mongo-tail-queries
yarn add mongo-tail-queries
bun add mongo-tail-queries
```

Provides the command `mongo-tail-queries`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-12-14 |
| First published | 2018-12-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | d1ma |
| Maintainers | d1ma |
| Keywords | mongo, mongodb, tail, log, mongotail, query |

## Links

- npm: https://www.npmjs.com/package/mongo-tail-queries
- Homepage: https://github.com/d1ma/mongo-tail-queries
- npm.io page: https://npm.io/package/mongo-tail-queries

## Dependencies (6)

- [mongodb](https://npm.io/package/mongodb.md) ^3.1.6
- [argparse](https://npm.io/package/argparse.md) ^1.0.10
- [pluralize](https://npm.io/package/pluralize.md) ^7.0.0
- [@types/argparse](https://npm.io/package/@types/argparse.md) ^1.0.34
- [password-prompt](https://npm.io/package/password-prompt.md) ^1.0.7
- [@types/underscore](https://npm.io/package/@types/underscore.md) ^1.8.9

## 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.2 (latest) — 2018-12-14
- 1.0.1 — 2018-12-14
- 1.0.0 — 2018-12-14

## README

## Description

This package allows you to tail all queries hitting a Mongo database. You'll see performance metrics associated with each query.

```
> mongo-tail-queries my_project -l 2
2018-12-03T21:58:23.153Z [UPDATE] users {"$and":[{"services.password.reset.reason":"enroll"},{"$or":[{"services.password.reset.when":{"$lt":"2018-11-03T21:58:23.149Z"}},{"services.password.reset.when":{"$lt":1541282303149}}]}],"_id":{"$in":[]}} {"$unset":{"services.password.reset":""}} : 0 updated. 0 examined. 0 millis.
2018-12-03T21:58:38.915Z [QUERY] users {"_id":"zmL8fgYCci3qfirbr"} : 1 returned. 1 examined. 0 millis.
2018-12-03T21:58:38.917Z [QUERY] chat_rooms {"_id":{"$in":[]},"members":"zmL8fgYCci3qfirbr","messages.sent":{"$gt":"2018-12-03T21:36:37.000Z"}} : 0 returned. 0 examined. 0 millis.
2018-12-03T21:59:25.185Z [COUNT] billing_history {} : 0 examined. 0 millis.
2018-12-03T21:59:32.091Z [QUERY] billing_history {} : 10 returned. 10 examined. 0 millis.
2018-12-03T21:59:32.094Z [QUERY] billing_history {"_id":{"$in":["B9cC9wPCANRcSM2fG","3NFtqgsDRdfEH4SWT","26SdMWXnokzPL7AiZ","TTsR5MXtrxnnbekci","Y6NGEBFwQWMhsgeeH","AhKfdLdQrTTouagvj","2dLEcfcDC8t6jrLk9","LqRCoBpuZDZ6iXeeH","vf3sCSZfisNPbfGx7","havDEy5egYR2cvReS"]}} : 10 returned. 10 examined. 0 millis.
2018-12-03T21:59:32.104Z [REMOVE] billing_history {}: 10 deleted. 10 examined. 0 millis.
2018-12-03T21:59:38.915Z [QUERY] users {"_id":"zmL8fgYCci3qfirbr"} : 1 returned. 1 examined. 0 millis.
```

## Installation

This will add the package as a CLI:
`npm install -g mongo-tail-queries`

## How it works

If you set up profiling, Mongo will log queries and metadata to a capped collection called "system.profile". This package opens a tailable cursor on this collection,
and prints the results as they come

## Running

Command to run

`node mongo-tail-queries [database] [options]`

or (if installed as CLI):

`mongo-tail-queries [database] [options]`

example: `node mongo-tail-queries 192.0.0.1:30001/my_project --authDB 'admin' --username 'tom' --password 'jerry' -l 2`

### Database

`database` argument should be formatted like `[ip]:[port]/[db_name]`. You can leave out the `[ip]:[port]` prefix to tail the `db_name` running locally (on `localhost:27017`).

### Options

| Argument             | Details                                                                       |
|----------------------|-------------------------------------------------------------------------------|
| --profilelevel or -l | Sets the profiling level. 0 is for none; 1 is for slow queries; 2 is for all. |
| --slowms or -s       | The cutoff for slow queries (if using profiling level 1). Default is 100ms.   |
| --authDB             |  the auth database to use to authenticate the user.                           |
| --username           | username for db access.                                                       |
| --password           | passsword for db access.                                                      |

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