fix: Upgrade readMany to readByQuery

It's a breaking change on 9.5.2 https://github.com/directus/directus/releases/tag/v9.5.2
This commit is contained in:
Simon 2022-02-21 17:33:50 +01:00
parent 9676d23fcc
commit adaba884fb
2 changed files with 7 additions and 6 deletions

View File

@ -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 ### Export to specific path
@ -73,9 +73,10 @@ const config = {
contentKey: 'body', contentKey: 'body',
collections: { collections: {
news: { news: {
readManyOption: { readByQueryOption: {
fields: ['title', 'slug', 'date', 'image', 'image_credit', 'draft', 'body'], fields: ['title', 'slug', 'date', 'image', 'image_credit', 'draft', 'body'],
filter: { draft: { _eq: 'false' } } filter: { draft: { _eq: 'false' } },
limit: -1
}, },
pathBuilder: (article) => { pathBuilder: (article) => {
if (article.slug) { if (article.slug) {

View File

@ -78,8 +78,8 @@ export default class DirectusToMarkdown {
async export() { async export() {
for (const collectionName in this.collections) { for (const collectionName in this.collections) {
const collection = this.collections[collectionName] const collection = this.collections[collectionName]
const readManyOption = collection.readManyOption const readByQueryOption = collection.readByQueryOption
const items = (await this.directus.items(collectionName).readMany(readManyOption)).data const items = (await this.directus.items(collectionName).readByQuery(readByQueryOption)).data
for (const item of items) { for (const item of items) {
const itemPath = collection.pathBuilder(item) const itemPath = collection.pathBuilder(item)
if (!fs.existsSync(itemPath)) { if (!fs.existsSync(itemPath)) {