VRMS icon indicating copy to clipboard operation
VRMS copied to clipboard

Implement a service for operating ProjectInfo entity

Open alex-anakin opened this issue 4 years ago • 1 comments

The task is blocked by:

  • [x] #456

Overview

Implement a service to operate the ProjectInfo data model.

Action Items

  • [ ] Add projectInfo.service.js into backend/services folder.
  • [ ] Implement createProject(projectInfo, authorEmail) function that returns the saved entity. Features:
  • Required fields for creating a project are the following:
    • name, type, description
    • locationZone, timeZone
    • activeStatus
    • urls: { hflaPage }
  • Validate required fields to be not empty.
  • Set field created using current date and time.
  • [ ] Implement updateProject(projectInfo, authorEmail) function that returns the updated entity. Features:
  • Use Mongoose findOneAndUpdate with id as a key.
  • Treat undefined fields as no-change
  • Removing required fields is not allowed and should be validated.
  • Set field lastModified using current date and time.
  • [ ] For both create and update functions:
  • Throw ValidationError if a change is not valid.
  • Wrap possible database errors into DatabaseError using try/catch.
  • Make a record in the ModificationLogs collection.
  • Place create/update actions into one transaction with saving logs.
  • [ ] Implement getProject(id) function that returns unique ProjectInfo entity.
  • [ ] Implement getActiveProjects() function that returns all ProjectInfo entities with activeStatus equals "Active".
  • [ ] Cover implemented functionality with tests.

Resources/Instructions

Service example Service test example

alex-anakin avatar Jan 25 '21 07:01 alex-anakin

I'm quite busy for the next week or so, and I won't be able to work on this. I'll move it back to the backlog. Thanks!

glenflorendo avatar Jul 16 '21 19:07 glenflorendo

Closed as not planned - planning on back end be People Depot. No longer relevant.

JackHaeg avatar Oct 31 '23 02:10 JackHaeg