Skip to content

Commit

Permalink
docs: add count method (#2200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barbapapazes committed Aug 1, 2023
1 parent d3ad72d commit d589e04
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/content/4.api/2.composables/1.query-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,27 @@ const [prev, next] = await queryContent()
null // no article-3 here
]
```

## `count()`

Count the number of matched contents based on the query.

```ts
// Count of articles
const count = await queryContent('articles').count()

// Returns
5 // number of articles
```

You can also use `count()` with `where()` method.

```ts
// Count of articles
const count = await queryContent('articles')
.where({ isArchived: false })
.count()

// Returns
5 // number of articles
```

0 comments on commit d589e04

Please sign in to comment.