Skip to content

Commit 465a6e0

Browse files
committed
fix: correct populate syntax for Strapi v5
Changed from array syntax populate: ['versions'] to object syntax populate: { versions: true } as per Strapi v5 Document Service API
1 parent e2b89bc commit 465a6e0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/src/services/email-designer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = ({ strapi }) => ({
9696
// Try as documentId (Strapi v5 standard)
9797
return strapi.documents(EMAIL_TEMPLATE_UID).findOne({
9898
documentId: String(idOrDocumentId),
99-
populate: ['versions'],
99+
populate: { versions: true },
100100
});
101101
},
102102

@@ -108,11 +108,11 @@ module.exports = ({ strapi }) => ({
108108
const numericId = Number(id);
109109
strapi.log.info(`[magic-mail] [LOOKUP] Finding template by numeric ID: ${numericId}`);
110110

111-
// 1. First try: Filter by templateReferenceId (unique integer field)
111+
// 1. First try: Filter by templateReferenceId (unique integer field) - Document Service
112112
const byRefId = await strapi.documents(EMAIL_TEMPLATE_UID).findMany({
113113
filters: { templateReferenceId: numericId },
114114
limit: 1,
115-
populate: ['versions'],
115+
populate: { versions: true },
116116
});
117117

118118
if (byRefId.length > 0) {
@@ -123,7 +123,7 @@ module.exports = ({ strapi }) => ({
123123
// 2. Fallback: Try internal database id via entityService (for backward compatibility)
124124
strapi.log.info(`[magic-mail] [FALLBACK] templateReferenceId not found, trying internal db id: ${numericId}`);
125125
const byInternalId = await strapi.entityService.findOne(EMAIL_TEMPLATE_UID, numericId, {
126-
populate: ['versions'],
126+
populate: { versions: true },
127127
});
128128

129129
if (byInternalId) {
@@ -448,7 +448,7 @@ module.exports = ({ strapi }) => ({
448448

449449
const version = await strapi.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
450450
documentId: versionDocumentId,
451-
populate: ['template'],
451+
populate: { template: true },
452452
});
453453

454454
if (!version) {
@@ -491,7 +491,7 @@ module.exports = ({ strapi }) => ({
491491

492492
const version = await strapi.documents(EMAIL_TEMPLATE_VERSION_UID).findOne({
493493
documentId: versionDocumentId,
494-
populate: ['template'],
494+
populate: { template: true },
495495
});
496496

497497
if (!version) {

0 commit comments

Comments
 (0)