fix(submissions): remove User model populate calls
- User is also a native MongoDB class, not Mongoose model - Removed all .populate() calls for createdBy, lastUpdatedBy, notes.author - These were causing MissingSchemaError for User model - Submissions can be returned without populated user data
This commit is contained in:
parent
b44686579a
commit
6011a50042
1 changed files with 4 additions and 10 deletions
|
|
@ -81,10 +81,9 @@ async function getSubmissions(req, res) {
|
|||
if (status) query.status = status;
|
||||
if (publicationId) query.publicationId = publicationId;
|
||||
|
||||
// NOTE: BlogPost is a native MongoDB class, not a Mongoose model,
|
||||
// so we can't use .populate() for blogPostId. Fetch blog post data separately if needed.
|
||||
// NOTE: BlogPost and User are native MongoDB classes, not Mongoose models,
|
||||
// so we can't use .populate() for them. Fetch data separately if needed.
|
||||
const submissions = await SubmissionTracking.find(query)
|
||||
.populate('createdBy', 'email')
|
||||
.sort({ submittedAt: -1, createdAt: -1 })
|
||||
.limit(parseInt(limit, 10))
|
||||
.skip(parseInt(offset, 10));
|
||||
|
|
@ -137,10 +136,7 @@ async function getSubmissionById(req, res) {
|
|||
try {
|
||||
const { id } = req.params;
|
||||
|
||||
const submission = await SubmissionTracking.findById(id)
|
||||
.populate('createdBy', 'email')
|
||||
.populate('lastUpdatedBy', 'email')
|
||||
.populate('notes.author', 'email');
|
||||
const submission = await SubmissionTracking.findById(id);
|
||||
|
||||
if (!submission) {
|
||||
return res.status(404).json({
|
||||
|
|
@ -318,9 +314,7 @@ async function getSubmissionByBlogPost(req, res) {
|
|||
try {
|
||||
const { blogPostId } = req.params;
|
||||
|
||||
const submission = await SubmissionTracking.findOne({ blogPostId })
|
||||
.populate('createdBy', 'email')
|
||||
.populate('lastUpdatedBy', 'email');
|
||||
const submission = await SubmissionTracking.findOne({ blogPostId });
|
||||
|
||||
if (!submission) {
|
||||
return res.status(404).json({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue