Follow+Notes: Add grant followers management to collaboration library #3203
Labels
collaboration
Grant Finder
Issues related to the Grant Finder
javascript
Pull requests that update Javascript code
Subtask of [STORY]: Update 'Status' to 'Follow + Note' feature #2960
Blocked by
Blocks
Definition of Done
The library at
packages/server/src/lib/grantsCollaboration
provides new exported functions for adding, removing, and retrieving followers of grants.Implementation Details
grant_followers
table with the following schema:id
: serial, not null, primary keygrant_id
: text, not null, foreign key togrants.grant_id
user_id
: int, not null, foreign key tousers.id
created_at
: timestamp with time zone, not null, defaultnow()
idx_grant_id_user_id
on columns(grant_id, user_id)
packages/server/src/lib/grantsCollaboration
library:followGrant(knex, grantId, userId)
(void)grant_followers
table to record that the identified user is now following the identified grant.knex
argument represents aknex
connection object, e.g. as exported bypackages/server/src/db/index.js
.knex
object may proceed. Therefore, this function should begin a new (sub-)transaction before insert, roll back the transaction on unique constraint violation, and commit the transaction following a successful insert.unfollowGrant(knex, grantId, userId)
(void)grant_followers
table.grantsCollaboration
library, they should be defined ingrantsCollaboration/followers.js
and imported/exported ingrantsCollaboration/index.js
.The text was updated successfully, but these errors were encountered: