# mongo-dot-notation-tool

> Tool for mongo dot-notation objects

Latest version **1.0.1** (published 2016-04-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install mongo-dot-notation-tool
pnpm add mongo-dot-notation-tool
yarn add mongo-dot-notation-tool
bun add mongo-dot-notation-tool
```

## 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.1 |
| Published | 2016-04-24 |
| First published | 2016-04-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alexey Kheben |
| Maintainers | aggregion |
| Keywords | mongo, mongodb, dotnotation, dot-notation, convert, converter, encode, decode |

## Links

- npm: https://www.npmjs.com/package/mongo-dot-notation-tool
- Repository: https://github.com/aggregion/mongo-dot-notation-tool
- Homepage: https://github.com/aggregion/mongo-dot-notation-tool#readme
- Issues: https://github.com/aggregion/mongo-dot-notation-tool/issues
- npm.io page: https://npm.io/package/mongo-dot-notation-tool

## 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.1 (latest) — 2016-04-24
- 1.0.0 — 2016-04-18

## README

# Mongo dot-notation tool
> <sup>Master</sup> [![Build Status](https://travis-ci.org/aggregion/mongo-dot-notation-tool.svg?branch=master)](https://travis-ci.org/aggregion/mongo-dot-notation-tool)

> <sup>Develop</sup> [![Build Status](https://travis-ci.org/aggregion/mongo-dot-notation-tool.svg?branch=develop)](https://travis-ci.org/aggregion/mongo-dot-notation-tool)

Convert dot-notation to simple JS object and back.

_Install_
```bash
npm install mongo-dot-notation-tool --save
```

_Use_
```javascript
var dotNotationTool = require('mongo-dot-notation-tool');
```

## Methods
### encode
Convert JS object to mongo dot-notation object
#### Use
```javascript
dotNotationTool.encode({name: {last: 'Foo', first: 'Bar'}});
// returns: {'name.last': 'Foo', 'name.first': 'Bar'}

dotNotationTool.encode({$and: [{name: {last: 'Foo'}}, {position: 'CTO'}]});
// returns: {$and: [{'name.last': 'Foo'}, {position: 'CTO'}]}

dotNotationTool.encode({
  $and: [
    {
      $or: [
        {
          name: {
            last: 'Foo'
          }
        },
        {
          name: {
            last: 'Bar'
          }
        }
      ],
      position: 'CTO'
    ]
  }
});
/*
returns: {
  $and: [
    {
      $or: [
        {
          'name.last': 'Foo'
        },
        {
          'name.last': 'Bar'
        }
      ],
      position: 'CTO'
    ]
  }
}
*/
```

### decode
Convert mongo dot-notation object to JS object
#### Use
```javascript
dotNotationTool.decode({'name.last': 'Foo', 'name.first': 'Bar'});
// returns: {name: {last: 'Foo', first: 'Bar'}}

dotNotationTool.decode({$and: [{'name.last': 'Foo'}, {position: 'CTO'}]});
// returns: {$and: [{name: {last: 'Foo'}}, {position: 'CTO'}]}

dotNotationTool.decode({
  $and: [
    {
      $or: [
        {
          'name.last': 'Foo'
        },
        {
          'name.last': 'Bar'
        }
      ],
      position: 'CTO'
    ]
  }
});
/*
returns: {
  $and: [
    {
      $or: [
        {
          name: {
            last: 'Foo'
          }
        },
        {
          name: {
            last: 'Bar'
          }
        }
      ],
      position: 'CTO'
    ]
  }
}
*/
```

### Run tests
```bash
npm test
# or
npm i
./node_modules/.bin/mocha ./test.js
# or
npm i -g mocha
mocha ./test.js
```

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