# mongobj

> Object operations in mongo api style

Latest version **1.0.9** (published 2019-05-29) · MIT license · 0 weekly downloads

## Install

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

## 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.9 |
| Published | 2019-05-29 |
| First published | 2019-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | quicksort |
| Maintainers | quicksort |
| Keywords | Object, Mongo, object update |

## Links

- npm: https://www.npmjs.com/package/mongobj
- Repository: https://github.com/quick-sort/mongobj
- Homepage: https://github.com/quick-sort/mongobj#readme
- Issues: https://github.com/quick-sort/mongobj/issues
- npm.io page: https://npm.io/package/mongobj

## 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.9 (latest) — 2019-05-29
- 1.0.8 — 2019-05-29
- 1.0.7 — 2019-05-05
- 1.0.6 — 2019-05-05
- 1.0.5 — 2019-04-29
- 1.0.4 — 2019-04-29
- 1.0.3 — 2019-03-29
- 1.0.2 — 2019-03-28
- 1.0.1 — 2019-03-28
- 1.0.0 — 2019-03-28

## README

MongObj
=======

MongObj is a Mongo-style api to update javascript object.

# Example
```js
import mongobj from 'mongobj'
let person = {
    "addresses": [
    {
        "country": "China",
        "city": "Shanghai",
        "street": [{
            "road": "Century Avenue",
            "room": "#201",
        }, {
            "road": "People Rd",
            "room": "#101"
        }]
    },
    {
        "country": "USA",
        "city": "Palo Alto"
    }
    ]
}
mongobj.update(person, {
    "$set": {
        "addresses.$[i].city": "Beijing"
    }
}, {
    "arrayFilters": [{"i.country": "China"}]
})

mongobj.update(person, {
    "$pull": {
        "addresses.$[i].street": { "road": "Century Avenue" }
    }
}, {
    "arrayFilters": [{"i.country": "China"}]
})

mongobj.update(person, {
    "$push": {
        "addresses": {
            "country": "France",
            "city": "Pairs"
        }
    }
})
mongobj.update(person, {
    "$unset": {
        "addresses.$[i].street": ""
    }
}, {
    "arrayFilters": [{"i.country": "China"}]
})
console.log(person)
```

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