# mongodb-xcollection

> MongoDB extended collection class that frees you from ObjectID and other Extended JSON type conversions.

Latest version **0.2.5** (published 2020-07-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mongodb-xcollection
pnpm add mongodb-xcollection
yarn add mongodb-xcollection
bun add mongodb-xcollection
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2020-07-16 |
| First published | 2020-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gustavo Gondim |
| Maintainers | ggondim |
| Keywords | mongodb, extended-json, bson, ext-json |

## Links

- npm: https://www.npmjs.com/package/mongodb-xcollection
- Repository: https://github.com/NOALVO/mongodb-xcollection
- Homepage: https://github.com/NOALVO/mongodb-xcollection#readme
- Issues: https://github.com/NOALVO/mongodb-xcollection/issues
- npm.io page: https://npm.io/package/mongodb-xcollection

## Dependencies (3)

- [ajv](https://npm.io/package/ajv.md) ^6.12.2
- [bson](https://npm.io/package/bson.md) ^4.0.4
- [@apidevtools/json-schema-ref-parser](https://npm.io/package/@apidevtools/json-schema-ref-parser.md) ^9.0.1

## 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

- 0.2.5 (latest) — 2020-07-16
- 0.2.4 — 2020-06-11
- 0.2.3 — 2020-06-09
- 0.2.2 — 2020-06-09
- 0.2.1 — 2020-06-09
- 0.2.0 — 2020-06-08
- 0.1.0 — 2020-06-08
- 0.0.2 — 2020-01-30
- 0.0.1 — 2020-01-30

## README

# DEPRECATION NOTICE

> ⚠ **This repository has been deprecated and archived in favor of the new [mongodb-proper-repository](https://github.com/ggondim/mongodb-proper-repository). This means its NPM package will be soon removed.**

Read more about [here](https://github.com/ggondim/mongodb-proper-repository#Ending-of-mongodb-pro-and-mongodb-xcollection).

<hr>

## mongodb-xcollection

MongoDB extended collection class that frees you from ObjectID and other Extended JSON type conversions.

## How to use

### Automatic conversion
```javascript
// considering you already have a `db` variable that is a native driver Db instance

const XCollection = require('mongodb-xcollection');
const Users = new XCollection(db, 'users');

// find
let users1 = await Users.find({ _id: { $oid: '5e332ae5f4744e0b08e510e8' } });

// insertOne
const createdUser1 = await Users.insertOne({ name: 'Gustavo' });
```

### Manual conversion
```javascript

// find
const findQuery = Users.convertInput({ _id: { $oid: '5e332ae5f4744e0b08e510e8' } });
const users2 = await Users.collection
  .find(findQuery)
  .toArray()
  .then(x => Users.convertOutput(x));

// insertOne
const newUser = Users.convertInput({ name: 'Gustavo' });
const createdUser2 = await Users.collection
  .insertOne(newUser)
  .then(x => Users.convertOutput(x.ops));
```

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