Skip to content

Commit 770b5fc

Browse files
Merge pull request #5 from Four-Lights-NL/fix-nested-repeatable-components
Fix repeatable nested components not being resolved correctly and add…
2 parents f6e7db0 + f4d21ab commit 770b5fc

File tree

13 files changed

+420
-856
lines changed

13 files changed

+420
-856
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,25 @@ Only relations that are actually set will be populated.
88

99
```ts
1010
// Option 1: get the populate object and use where you see fit
11-
const populate = await strapi.plugin("deep-populate").service("populate").getPopulate({ documentId: 'xyz', contentType: 'api::page.page' })
11+
const populate = await strapi.plugin("deep-populate").service("populate").get({ documentId: 'xyz', contentType: 'api::page.page' })
1212
const document = strapi.documents('api::page.page').findOne({ documentId: 'xyz', populate })
1313
```
1414
```ts
15-
// Option 2: use the wrapped `findOne` method around documentService
15+
// Option 2: use the `findOne` method that wraps around documentService.findOne
1616
const { findOne } = strapi.plugin("deep-populate").service("populate").documents("api::page.page")
1717
const document = await findOne({ documentId: 'xyz' })
18+
```
19+
20+
```ts
21+
// Using the wrapped FindOne provides some handy features:
1822

19-
// You can also override the populate this way:
23+
// Allow you to override the populate this way:
2024
const documentWithCreatedBy = findOne({ documentId: 'xyz', populate: ['createdBy']})
2125
const documentWithoutSection = findOne({ documentId: 'xyz', populate: { section: false }})
26+
27+
// And if you supply a `*` as populate, it will return a fully populated document (i.e. non-sparse)
28+
const sparseDocument = findOne({ documentId: 'xyz' }) // sparse, so only attributes are returned that have a value
29+
const fullDocument = findOne({ documentId: 'xyz', populate: '*' }) // fully populated, so all attributes are returned
2230
```
2331

2432
### populateCreatorFields

0 commit comments

Comments
 (0)