Skip to content

Commit

Permalink
docs(readme): explain how to catch already exists error 📝
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioArnt committed Sep 27, 2019
1 parent 1940d3e commit 1294c07
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ const classic = new Album({
await album.save();

// Will throw, as item already exists
await album.create();
try {
await album.create();
} catch (e) {
if (e.name === 'EALREADYEXISTS') {
// Do something
}
// Do something else
}
```

You can also directly pass in argument the item to save.
Expand Down

0 comments on commit 1294c07

Please sign in to comment.