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

queryCollection.('collection_name').skip() and queryCollection.('collection_name').where(key, 'LIKE', value) or where(key, 'IN', array) not working for version 3.2.2 #3214

Closed
fandy8255 opened this issue Mar 2, 2025 · 2 comments
Labels
v2 Relevant for @nuxt/content v2

Comments

@fandy8255
Copy link

Environment



Version

v3.2.2

Reproduction

https://stackblitz.com/edit/github-9ynqdouz?file=app%2Fpages%2F%5B...slug%5D.vue

Description

Ive not been able to use .skip() for my articles.md queries and aso not been able to filter articles by tag_names,

queryCollection('blog').skip(2).all() is not working
queryCollection('blog').where('tags', 'IN', 'tag_name').all() is not working

Here is a small fragment reproducing the issue, what could be the problem here? Thanks

{{ article.id }}
no articles found
<script setup> import { onMounted } from 'vue'; useHead({ link: { rel: 'stylesheet', href: 'https://unpkg.com/[email protected]/components/blogs/blog-3/assets/css/blog-3.css', }, }); const articles = useState('articles'); onMounted(async () => { /* const { data } = await useAsyncData('blog', () => queryCollection('blog').where('category', '=', 'Instagram').all() ); */ //WORKING //const { data } = await useAsyncData('blog', () => queryCollection('blog').limit(1).all()) //WORKING const { data } = await useAsyncData('blog', () => queryCollection('blog').skip(2).all() ); //NOT WORKING //console.log('data', data); /* const { data } = await useAsyncData('blog', () =>{ return queryCollection('blog').where('tags','IN','Vue').all() })*/ //NOT WORKING console.log('blog data', data); articles.value = data; window.scrollTo(0, 0); }); </script> <style> .hero-section { background: linear-gradient(to bottom right, #ff7eb9, #ff758c); color: white; /*height: 90vh;*/ width: 100%; background-image: url('/assets/images/hero-banner.jpg'); background-size: cover; background-position: center; /*padding: 100px 0;*/ } a { color: azure; } @media only screen and (max-width: 600px) { #main-container { padding: 1vw; } } </style>

Additional context

No response

Logs

@fandy8255 fandy8255 added the v2 Relevant for @nuxt/content v2 label Mar 2, 2025
@fandy8255 fandy8255 changed the title .skip() and where(key, 'LIKE', value) or where(key, 'IN', array) not working .skip() and where(key, 'LIKE', value) or where(key, 'IN', array) not working for version 3.2.2 Mar 2, 2025
@fandy8255 fandy8255 changed the title .skip() and where(key, 'LIKE', value) or where(key, 'IN', array) not working for version 3.2.2 queryCollection.('collection_name').skip() and queryCollection.('collection_name').where(key, 'LIKE', value) or where(key, 'IN', array) not working for version 3.2.2 Mar 2, 2025
@fandy8255
Copy link
Author

okay so i found that skip() only works when limit is also chained :

queryCollection('blog') .order('date', 'DESC') .skip(skip) .limit(itemsPerPage) .all() ,
what still isnt working is :

const { data } = await useAsyncData('blog', () =>{ return queryCollection('blog').where('tags','IN','Instagram').all() }) im trying to query articles with a specific tag ,

here is how the frontmatter looks like:

`---
title: Article Three
subtitle: La Mejor De Todas
description: and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.
image: 'https://i.ib.co/HgwqGW/1.jpg'
tags: ['VueJS', 'Nuxt', 'Instagram']
published: true
category: Instagram
date: '2025-03-01'

Getting started

Empower your NuxtJS application with @nuxtjs/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.

Writing content

Learn how to write your content/, supporting Markdown, YAML, CSV and JSON: https://content.nuxtjs.org/writing.

Fetching content

Learn how to fetch your content with $content: https://content.nuxtjs.org/fetching.

Displaying content

Learn how to display your Markdown content with the <nuxt-content> component directly in your template: https://content.nuxtjs.org/displaying.

image

Alt text
`

@farnabaz
Copy link
Member

farnabaz commented Mar 3, 2025

This is indeed an SQL restriction, You can use limit separately, but if you use skip you need to define limit too.

About the array search, IN is not what you expect. You can use LIKE operator to match the tag

Checkout #2960 (comment)

Closing this to followup in #2960

@farnabaz farnabaz closed this as completed Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Relevant for @nuxt/content v2
Projects
None yet
Development

No branches or pull requests

2 participants