Backend: Save a New Project to an Existing Collection (or Auto create the collection) #1213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #1194
Linked to parent issue: #1180
Project Published URL 🔗
Backend-only change. Tested locally using Postman
Description 📃
Implemented backend logic to allow users to save a project into their saved collections.
Added auto-creation of a collection if it does not already exist.
Prevented duplicate project entries inside the same collection.
Used req.user from authentication middleware to ensure only logged-in users can save projects.
Response returns appropriate messages (new collection created, project saved, or duplicate prevention).
Added comments for readability and understanding
Screenshots 📷



fig1: automatically adding project to default collection and saving project
fig2: duplicate projects check in same collection
fig3: added to an existing collection
Type of change ☑️
What sort of change have you made:
[☑️ ] New feature
[☑️ ] Database update
Note to reviewers 📄
This is a backend-only feature and does not require frontend updates.
Kindly review the collection auto-creation logic and suggest if collection schema needs adjustment for multiple project references instead of separate documents.
Always open for feedbacks!!