Skip to content

Commit c6f0f8b

Browse files
committed
Change populate to populateEntryRule
1 parent 4a8a288 commit c6f0f8b

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,11 @@ module.exports = {
350350

351351
[See resources](./resources/meilisearch-settings) for more settings examples.
352352

353-
#### 👥 Populate
353+
#### 👥 Populate entry rule
354354

355355
Content-types in Strapi may have relationships with other content-types. To ensure that these links are fetched and added to an entry correctly from your Strapi database, the correct populate rule must be provided ([see documentation](https://docs-next.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/entity-service/populate.html#basic-populating)).
356356

357-
To communicate the populate rule, use the `populate` setting on the according content-type in the plugin's settings.
357+
To communicate the populate rule, use the `populateEntryRule` setting on the according content-type in the plugin's settings.
358358

359359
**For example**
360360

@@ -367,7 +367,7 @@ module.exports = {
367367
meilisearch: {
368368
config: {
369369
restaurant: {
370-
populate: ['repeatableComponent.categories', 'categories'],
370+
populateEntryRule: ['repeatableComponent.categories', 'categories'],
371371
}
372372
}
373373
},

server/__tests__/configuration-validation.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,46 +212,46 @@ describe('Test plugin configuration', () => {
212212
expect(fakeStrapi.log.error).toHaveBeenCalledTimes(0)
213213
})
214214

215-
test('Test populate with wrong type', async () => {
215+
test('Test populateEntryRule with wrong type', async () => {
216216
validateConfiguration({
217217
restaurant: {
218-
populate: 0,
218+
populateEntryRule: 0,
219219
},
220220
})
221221
expect(fakeStrapi.log.warn).toHaveBeenCalledTimes(0)
222222
expect(fakeStrapi.log.error).toHaveBeenCalledTimes(1)
223223
expect(fakeStrapi.log.error).toHaveBeenCalledWith(
224-
'the "populate" param of "restaurant" should be an object/array/string'
224+
'the "populateEntryRule" param of "restaurant" should be an object/array/string'
225225
)
226226
})
227227

228-
test('Test populate with function', async () => {
228+
test('Test populateEntryRule with function', async () => {
229229
validateConfiguration({
230230
restaurant: {
231-
populate: () => {},
231+
populateEntryRule: () => {},
232232
},
233233
})
234234
expect(fakeStrapi.log.warn).toHaveBeenCalledTimes(0)
235235
expect(fakeStrapi.log.error).toHaveBeenCalledTimes(1)
236236
expect(fakeStrapi.log.error).toHaveBeenCalledWith(
237-
'the "populate" param of "restaurant" should be an object/array/string'
237+
'the "populateEntryRule" param of "restaurant" should be an object/array/string'
238238
)
239239
})
240240

241-
test('Test populate with empty object', async () => {
241+
test('Test populateEntryRule with empty object', async () => {
242242
validateConfiguration({
243243
restaurant: {
244-
populate: {},
244+
populateEntryRule: {},
245245
},
246246
})
247247
expect(fakeStrapi.log.warn).toHaveBeenCalledTimes(0)
248248
expect(fakeStrapi.log.error).toHaveBeenCalledTimes(0)
249249
})
250250

251-
test('Test populate with undefined', async () => {
251+
test('Test populateEntryRule with undefined', async () => {
252252
validateConfiguration({
253253
restaurant: {
254-
populate: undefined,
254+
populateEntryRule: undefined,
255255
},
256256
})
257257
expect(fakeStrapi.log.warn).toHaveBeenCalledTimes(0)

server/configuration-validation.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function validateCollectionConfiguration({ configuration, collection }) {
4747
'transformEntry',
4848
'settings',
4949
'filterEntry',
50-
'populate',
50+
'populateEntryRule',
5151
]
5252

5353
if (configuration === undefined) {
@@ -100,15 +100,15 @@ function validateCollectionConfiguration({ configuration, collection }) {
100100
}
101101

102102
if (
103-
configuration.populate !== undefined &&
104-
!isObject(configuration.populate) &&
105-
!Array.isArray(configuration.populate) &&
106-
typeof configuration.populate !== 'string'
103+
configuration.populateEntryRule !== undefined &&
104+
!isObject(configuration.populateEntryRule) &&
105+
!Array.isArray(configuration.populateEntryRule) &&
106+
typeof configuration.populateEntryRule !== 'string'
107107
) {
108108
strapi.log.error(
109-
`the "populate" param of "${collection}" should be an object/array/string`
109+
`the "populateEntryRule" param of "${collection}" should be an object/array/string`
110110
)
111-
delete configuration.populate
111+
delete configuration.populateEntryRule
112112
}
113113

114114
Object.keys(configuration).forEach(attribute => {

server/services/lifecycle/lifecycle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = ({ strapi }) => {
2828
const entry = await contentTypeService.getEntry({
2929
contentType: contentTypeUid,
3030
id: result.id,
31-
populate: meilisearch.populateRule({ contentType }),
31+
populate: meilisearch.populateEntryRule({ contentType }),
3232
})
3333

3434
meilisearch
@@ -58,7 +58,7 @@ module.exports = ({ strapi }) => {
5858
const entry = await contentTypeService.getEntry({
5959
contentType: contentTypeUid,
6060
id: result.id,
61-
populate: meilisearch.populateRule({ contentType }),
61+
populate: meilisearch.populateEntryRule({ contentType }),
6262
})
6363

6464
meilisearch

server/services/meilisearch/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ module.exports = ({ strapi }) => {
3636
},
3737

3838
/**
39-
* Get the populate rules to apply when fetching entries in the Strapi database.
39+
* Get the populate rule of a content-type that is applied when fetching entries in the Strapi database.
4040
*
4141
* @param {object} options
4242
* @param {string} options.contentType - ContentType name.
4343
*
4444
* @return {String} - Populate rule.
4545
*/
46-
populateRule: function ({ contentType }) {
46+
populateEntryRule: function ({ contentType }) {
4747
const collection = contentTypeService.getCollectionName({ contentType })
4848
const contentTypeConfig = meilisearchConfig[collection] || {}
4949

server/services/meilisearch/connector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ module.exports = ({ strapi, adapter, config }) => {
286286
const tasksUids = await contentTypeService.actionInBatches({
287287
contentType,
288288
callback: addDocuments,
289-
populate: config.populateRule({ contentType }),
289+
populate: config.populateEntryRule({ contentType }),
290290
})
291291

292292
await store.addIndexedContentType({ contentType })
@@ -345,7 +345,7 @@ module.exports = ({ strapi, adapter, config }) => {
345345
await contentTypeService.actionInBatches({
346346
contentType,
347347
callback: deleteEntries,
348-
populate: config.populateRule({ contentType }),
348+
populate: config.populateEntryRule({ contentType }),
349349
})
350350
} else {
351351
const { apiKey, host } = await store.getCredentials()

0 commit comments

Comments
 (0)