parmetra
Explore posts from serversDTDrizzle Team
•Created by parmetra on 11/20/2023 in #help
Using 'where' inside 'with'
As a temporary solution, I did via selectDistinct(bellow), but I'd still like to figure out why where inside with doesn't want to trigger like in the documentation.
const articles = await this.db
.selectDistinct({
id: article.id,
slug: article.slug,
title: article.title,
description: article.description,
body: article.body,
createdAt: article.createdAt,
updatedAt: article.updatedAt,
tagList: article.tagList,
favoritesCount: article.favoritesCount,
author: {
id: user.id,
username: user.username,
email: user.email,
bio: user.bio,
image: user.image,
},
})
.from(article)
.where(
queryParam?.author && eq(user.username, queryParam?.author)
)
.leftJoin(user, eq(article.authorId, user.id))
.limit(query?.limit)
.offset(query?.offset)
.orderBy(desc(article.createdAt));
10 replies
DTDrizzle Team
•Created by parmetra on 11/20/2023 in #help
Using 'where' inside 'with'
The API specification needs the response to look like this:
{
"id": 37,
"slug": "article-first-kmisni",
"title": "Article first",
"description": "Article descr",
"body": "Article body",
"createdAt": "2023-11-21T09:41:50.275Z",
"updatedAt": null,
"tagList": [],
"favoritesCount": 0,
"author": {
"id": 35,
"username": "john",
"email": "[email protected]",
"bio": null,
"image": null
}
}
So we should get articles, and inside each article there should be information about its author.10 replies
DTDrizzle Team
•Created by Louistiti on 7/15/2023 in #help
Use Drizzle in NestJS app
Hello! Is this a working solution?
16 replies