# mongo-why
Tells you why mongo fails to validate your document.

## Use case

```
$ mongo
> load('why.js')
true
> why('collectionName', {...The object that failed to insert...})
-------------------------
Unmatched validator rules
-------------------------
[
  ...
]
```


## Unit test

```
$ mongo test.js
MongoDB shell version: 3.2.4
connecting to: test
# If there is no assertion errors, the test passes.
```

# mongo-why
Tells you why mongo fails to validate your document.

## Use case

Load `why.js` into mongo shell, then use `why(<name of collection>, <the document you want to insert>)`

```
$ mongo
> load('why.js')
true
> why('collectionName', {...The document that failed to insert...})
-------------------------
Unmatched validator rules
-------------------------
[
  ...
]
```

Under the hood, it applies *parts of* the specified collection's validator to a temporary collection, and tries inserting the document into that temporary collection. Then it prints out the parts of the validator that cannot validate the document.

## Unit test

```
$ mongo test.js
MongoDB shell version: 3.2.4
connecting to: test
# If there is no assertion errors, the test passes.
```

Add more info in readme
Add more info in readme