Skip to content
Discussion options

You must be logged in to vote

What is in your where? If you are filtering only on stuff from your article, this is a solution:

const articlesSQ = db
    .select()
    .from(schema.article)
    .orderBy(
        desc(schema.article.publishedAt),
        desc(schema.article.title),
     )
    .where(...)
    .offset((page - 1) * LIMIT)
    .limit(LIMIT)
    .as("articlesSQ")

const articles = await db
    .select()
    .from(articlesSQ)
    .leftJoin(
        schema.heading,
        eq(articleSQ.id, schema.heading.articleId)
    );

You might need to add the selected columns to your select for this to work properly. I didn't test.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@arashi-dev
Comment options

@Angelelz
Comment options

@arashi-dev
Comment options

Answer selected by arashi-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants