The current response schema works fine in all uses cases of Content module, However there are some limitations in supporting new features like paginations. Therefore I'm suggestion a change in API's response data in order to unlock new possibilities and improve query performance
Currently Content's query api returns:
A list of matched contents in case of find
A single content in case of findOne
Proposed Schema
interface FindResponseSchema<T extends ParsedContent> {
result: T[]
limit: number
skip: number
total: number
}
interface FindOneResponseSchema<T extends ParsedContent> {
result: T | null
}
interface CountResponseSchema {
result: number
}
Here is some examples of what we can achieve with the new schema:
Surround
Find a content with it's surroundings (instead of calling findOne and findSurround as two separate queries).
These two queries are most used queries in Content module which executes by default in document-driven. Combining them can reduce 1 request from almost all pages of a Nuxt Content website. Checkout docus.dev, alpine.nuxt.space
interface FindResponseSchema<T extends ParsedContent> {
result: T[]
limit: number
skip: number
total: number
pagination: {
/**
* Current page
*/
current: number
/**
* Total number of pages
*/
total: number
/**
* URL of next page
*/
nextURL: string
}
}
contentQuery('/parent')
.withPagination()
.find()
_dir.yml load
New schema will allow users to fetch settings inside _dir.yml for a content and use it as a place to define
interface FindResponseSchema<T extends ParsedContent> {
result: T[]
limit: number
skip: number
total: number
dirConfig: Record<string, any>
}
contentQuery('/parent/child')
.withDirConfig()
.findOne()
Looking forward to get your feedbacks and ideas about this change.
The current response schema works fine in all uses cases of Content module, However there are some limitations in supporting new features like paginations. Therefore I'm suggestion a change in API's response data in order to unlock new possibilities and improve query performance
Currently Content's query api returns:
find
findOne
Proposed Schema
Here is some examples of what we can achieve with the new schema:
Surround
Find a content with it's surroundings (instead of calling
findOne
andfindSurround
as two separate queries). These two queries are most used queries in Content module which executes by default in document-driven. Combining them can reduce 1 request from almost all pages of a Nuxt Content website. Checkout docus.dev, alpine.nuxt.spacePagination
_dir.yml
loadNew schema will allow users to fetch settings inside
_dir.yml
for a content and use it as a place to defineLooking forward to get your feedbacks and ideas about this change.