# Migrate to version 2

## Purpose

In order to use `chpr-mongodb` with new mongodb version 4.2 we need to upgrade  to lastest
version of the mongodb driver. This new version introduce some breaking changes.

> :warning: **Projection have changed**

The main difference is how to do a projection on fields with find* requests,
now the second argument is a options object (more info [here](https://mongodb.github.io/node-mongodb-native/3.3/api/Collection.html#find))

### Example

This legacy code:
```js
  collection(mongodb).find({
    associated_at: { $lt: deletionDate },
  }, { subscription_id: 1 });
```

became:

```js
  collection(mongodb).find({
    associated_at: { $lt: deletionDate },
  }, { projection: { subscription_id: 1 } });
```

### Throwing

To avoid silently error with projection `chpr-mongodb` throw an error *InvalidArgument* if the second parameter
of `find*` is invalid.
