LoopBack — MongoDB ToDo

We will be making an API that will use MongoDB for its database.
The ids are going to be tricky on this one. Fear not as long as you follow closely things will work.
After creating an api with loop back. If you still have doubts on how to do that, follow my previous story, we need to install a npm package to connect loopback and mongo db.
npm i -s loopback-connector-mongodb
As always we start with the model:
lb4 model todo

Make sure that the first property is “id” and that it isn’t automatically generated nor required, also keep it as a string.
Then we go for the datasource:
lb4 datasource todo

Now the repository:
lb4 repository todo

Finally the controller:
lb4 controller todo

And now we are ready to run the API.
Now try testing it on the swagger ui found at: localhost:3000/explorer