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
@ -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) {

View File

@ -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)) {