Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support directus deep query parameter #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ So, configuration should comes from one of next files:
- `reindexOnStart: boolean` Performs full reindex of all documents upon Directus starts
- `collections: object` Indexing data definition
- `collections.<collection>.filter: object` The filter query in format like Directus on which item must match to be
indexed (check [Filter Rules ](https://docs.directus.io/reference/filter-rules/#filter-rules))
indexed (check [Filter Rules](https://docs.directus.io/reference/filter-rules/#filter-rules))
- `collections.<collection>.deep: object` The deep query in format like Directus on which item must match to be
indexed (check [Deep Parameter](https://docs.directus.io/reference/query.html#deep))
- `collections.<collection>.fields: array<string>` Fields that will be indexed in Directus format
- `collections.<collection>.transform: function` (Could be defined only if config file is .js) A callback to return
transformed/formatted data for indexing.
Expand Down
2 changes: 2 additions & 0 deletions lib/create-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function createIndexer(config, { logger, database, services, getSchema }) {
const items = await query.readByQuery({
fields: [pk],
filter: config.collections[collection].filter || [],
deep: config.collections[collection].deep || {},
limit,
offset,
});
Expand Down Expand Up @@ -121,6 +122,7 @@ function createIndexer(config, { logger, database, services, getSchema }) {
const items = await query.readMany(ids, {
fields: config.collections[collection].fields ? [pk, ...config.collections[collection].fields] : ['*'],
filter: config.collections[collection].filter || [],
deep: config.collections[collection].deep || {},
});

/**
Expand Down