A Mongoose schema defines the structure of the documents that you can store in a MongoDB collection and provides an interface for creating, reading, updating, and deleting documents in that collection. The first thing is to select the request type as POST, and use the following url (don’t forget to change to your own. A Mongoose model is a schema-based class in Mongoose that allows you to interact with a MongoDB collection. To create a game, we need to make a post request and send a Json object in the request’s body. In this section I’m gonna show you how to use our API to create, edit, read, delete and from game collection. Postman is a HTTP client used for testing APIs. If we take a look on the Put and Delete methods, we see this behavior happening. One thing to point out, there are some actions receiving the id as a string instead of a ObjectId, because is more practical to send just the string that ObjectId generates and create the ObjectId in the back-end code. The file has comments, such as, // GET: api/Game, this is to show how can we make a request to a certain method on the API. MongoDB Compass, a powerful GUI for querying, aggregating, and analyzing your MongoDB. Since it’s a RestAPI, we have all actions needed, like, Get, Post, Put and Delete. We’re using all methods created on the repository to query and execute actions in the database. Public class GameRepository : IGameRepository A web-based MongoDB admin interface written with Node.js, Express, and Bootstrap3.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |