Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

feat(nuxt): filter support for clearNuxtData#7323

Merged
pi0 merged 1 commit intonuxt:mainfrom
cawa-93:feat/clearNuxtDataByFilter
Sep 7, 2022
Merged

feat(nuxt): filter support for clearNuxtData#7323
pi0 merged 1 commit intonuxt:mainfrom
cawa-93:feat/clearNuxtDataByFilter

Conversation

@cawa-93
Copy link
Copy Markdown
Contributor

@cawa-93 cawa-93 commented Sep 7, 2022

🔗 Linked issue

Continuation of #5227

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Uncovered use case:
Remove cache for several unknown keys. Example: you have app with posts and filter for posts. Each query for posts saved in cache in uniq key, like posts.list-{param1:1}, posts.list-{param2:2}, posts.list-{param1:1,param2:3} (nuxt-trpc works llike that). In this case you may want clear data for all keys posts.list-*.
May be clearNuxtData should also accept function to filter keys?

clearNuxtData(key => key.startsWith('posts.list'))

Or provide another method to get all keys in cache and filter it manually:

clearNuxtData(
  getNuxtDataKeys().filter(key => key.startsWith('posts.list'))
)

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 7, 2022

Deploy Preview for nuxt3-docs ready!

Name Link
🔨 Latest commit ba4828c
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/63188baaed3c8800081e3be1
😎 Deploy Preview https://deploy-preview-7323--nuxt3-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@atinux
Copy link
Copy Markdown
Member

atinux commented Sep 7, 2022

I do like the idea of a filter method ☺️

@atinux
Copy link
Copy Markdown
Member

atinux commented Sep 7, 2022

Wondering if this could be applied also to refreshNuxtData(): https://v3.nuxtjs.org/api/utils/refresh-nuxt-data

@cawa-93
Copy link
Copy Markdown
Contributor Author

cawa-93 commented Sep 7, 2022

@pi0
Copy link
Copy Markdown
Member

pi0 commented Sep 7, 2022

LGTM. Supporting for refreshNuxtData is also good idea. We can implement similar for fallback when no keys are set. (PR welcome)

@pi0 pi0 changed the title feat: add filter for clearNuxtData feat(nuxt): filter support for clearNuxtData Sep 7, 2022
@pi0 pi0 merged commit 6b3a1a4 into nuxt:main Sep 7, 2022
@cawa-93 cawa-93 deleted the feat/clearNuxtDataByFilter branch September 7, 2022 13:32
This was referenced Sep 9, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants