REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 1.14 KB
Close
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/lib/backend/utils/populator/populator.doc.md
Text
Base64
Populates all references in records. ### Usage Take a look at an example action handler getting the Product record and populates it. We assume that Product has categoryId and it is marked as a 'reference' ({@link PropertyOptions#reference}) to a Category. ```javascript const { populator } = require('adminjs') // action handler for showing product with categories const showProductsHandler = async (request, response, context) => { const { payload } = request const { _admin, currentAdmin } = context const ProductResource = _admin.findResource('Product') const product = await ProductResource.findOne() // product.populated is empty const [populatedProduct] = await populator([product]) // populatedProduct.populated - has a categoryId filled with Category params return { record: record.toJSON(currentAdmin) // returns RecordJSON with populated field as well } } ``` ### Where you might want to use it? Populator is used in all built-in actions so you don't need to take care of populating fields on your own. Situation changes when you want to create a custom action and use data not from the context but right from the database query.
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 6
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
index.js
71 B
lrw-r--r--
2026-02-28 00:31:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
populate-property.js
3.79 KB
lrw-r--r--
2026-02-28 00:31:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
populate-property.spec.js
4.30 KB
lrw-r--r--
2026-02-28 00:31:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
populator.doc.md
1.14 KB
lrw-r--r--
2026-02-28 00:31:56
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
populator.js
674 B
lrw-r--r--
2026-02-28 00:31:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
populator.spec.js
323 B
lrw-r--r--
2026-02-28 00:31:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).