cornellh4i / greenzone

A data visualization tool for Mongolian rangeland herders.
MIT License
0 stars 0 forks source link

Constructing endpoints for Database #59

Closed snehar27 closed 1 week ago

snehar27 commented 2 weeks ago

Overview

In this ticket, we worked on creating the GET, POST, PUT, and DELETE requests for the Hexagon, Province, and County objects.

Testing

We utilized postman to test these endpoints. First, ensure that you are in the backend folder. Then, run npm start in the terminal so connect to the database server. Follow the following steps to test that the endpoints work:

POST:

  1. In the body tab in Postman, add the attributes of the object (ie. specify what all of the fields for the hexagon, province or county object should be so that you can create a new object).
  2. Add the url of the request and make sure that POST is selected
  3. Send the request. This should have created a new object and added it to the database.

GET:

  1. Check that the url of the request is correct and make sure that GET is selected
  2. Send the request. If an object of the type being tested has been created, it should be listed as one in the database.

UPDATE:

  1. Choose an object to update. Then, copy its id for future use.
  2. Choose an attribute of the object to update, and in the body, specify what the attribute should be updated to.
  3. Add the id to the end of the url (like this: /[_id]) and make sure that PUT is selected.
  4. Send the request. If you run GET again, you should see that this object has been updated with the specified attribute.

DELETE:

  1. Choose an object to delete. Then, copy its id for future use.
  2. Add the id to the end of the url (just like in update) and make sure that DELETE is selected.
  3. Send the request. If you run GET again, you should see that this object has been deleted.

Impact

This PR will help with creating and editing objects in the database.

Notes

Very small thing for counties - when creating the requests for counties, county was used instead of soum so that it is consistent with the attributes in the schema. However, changing it to soum is an easy fix, so feel free to let us know if this change should be made!