As mentioned previously, you can use include to fetch related 'edges' of a queried item. Instead of manually storing IDs and performing multiple round-trips, Alinea provides built-in relational querying for a more seamless developer experience.
await cms.first({
type: DocsSchema,
include: {
parents: Query.parents({
select: {
url: Query.url,
title: Query.title
}
}),
children: Query.children({
type: Doc,
select: {
url: Query.url,
title: Query.title
}
}),
siblings: Query.siblings({
type: Docs,
select: {
url: Query.url,
title: Query.title
}
})
}
})You can also leverage previous and next helpers for sequential navigation, ideal for building components like the pagination links at the bottom of this page.
await cms.first({
type: DocSchema,
include: {
previous: Query.previous({
select: {
url: Query.url,
title: Query.title
}
}),
next: Query.next({
select: {
url: Query.url,
title: Query.title
}
})
}
})Fetches translations of the current entry by locale.
await cms.first({
type: DocSchema,
include: {
translations: Query.translations({
select: {locale: Query.locale, url: Query.url}
})
}
})