From adaba884fb909b2052adefbd8b72cfa542b22baa Mon Sep 17 00:00:00 2001 From: Simon C Date: Mon, 21 Feb 2022 17:33:50 +0100 Subject: [PATCH] fix: Upgrade readMany to readByQuery It's a breaking change on 9.5.2 https://github.com/directus/directus/releases/tag/v9.5.2 --- README.md | 9 +++++---- index.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 492c7f3..3f6e1b9 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ const config = { } ``` -### readManyOption +### readByQueryOption -`readManyOption` match https://docs.directus.io/reference/sdk/#read-multiple-items +`readByQueryOption` match https://docs.directus.io/reference/sdk/#read-by-query ### Export to specific path @@ -73,9 +73,10 @@ const config = { contentKey: 'body', collections: { news: { - readManyOption: { + readByQueryOption: { fields: ['title', 'slug', 'date', 'image', 'image_credit', 'draft', 'body'], - filter: { draft: { _eq: 'false' } } + filter: { draft: { _eq: 'false' } }, + limit: -1 }, pathBuilder: (article) => { if (article.slug) { diff --git a/index.js b/index.js index 471e1bd..4526133 100644 --- a/index.js +++ b/index.js @@ -78,8 +78,8 @@ export default class DirectusToMarkdown { async export() { for (const collectionName in this.collections) { const collection = this.collections[collectionName] - const readManyOption = collection.readManyOption - const items = (await this.directus.items(collectionName).readMany(readManyOption)).data + const readByQueryOption = collection.readByQueryOption + const items = (await this.directus.items(collectionName).readByQuery(readByQueryOption)).data for (const item of items) { const itemPath = collection.pathBuilder(item) if (!fs.existsSync(itemPath)) {