File tree Expand file tree Collapse file tree 6 files changed +12
-8
lines changed
[username]/[articleHandle] Expand file tree Collapse file tree 6 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11import HomeLeftSidebar from "@/app/(home)/_components/HomeLeftSidebar" ;
2+ import { persistenceRepository } from "@/backend/persistence-repositories" ;
3+ import { eq } from "@/backend/persistence/persistence-where-operator" ;
24import * as articleActions from "@/backend/services/article.actions" ;
35import AppImage from "@/components/AppImage" ;
4- import type { Article , WithContext } from "schema-dts" ;
56import HomepageLayout from "@/components/layout/HomepageLayout" ;
67import { readingTime , removeMarkdownSyntax } from "@/lib/utils" ;
8+ import getFileUrl from "@/utils/getFileUrl" ;
79import { markdocParser } from "@/utils/markdoc-parser" ;
8- import { Metadata , NextPage , ResolvingMetadata } from "next" ;
10+ import { Metadata , NextPage } from "next" ;
911import Image from "next/image" ;
1012import Link from "next/link" ;
1113import { notFound } from "next/navigation" ;
14+ import type { Article , WithContext } from "schema-dts" ;
1215import ArticleSidebar from "./_components/ArticleSidebar" ;
13- import getFileUrl from "@/utils/getFileUrl" ;
14- import { persistenceRepository } from "@/backend/persistence-repositories" ;
15- import { eq } from "@/backend/persistence/persistence-where-operator" ;
1616
1717interface ArticlePageProps {
1818 params : Promise < {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { getTags } from "@/backend/services/tag.action";
22import React from "react" ;
33
44const Page = async ( ) => {
5- const tags = await getTags ( { page : 1 , limit : - 1 } ) ;
5+ const tags = await getTags ( { page : 1 , limit : - 1 , search : "ww" } ) ;
66 return < pre className = "p-10" > { JSON . stringify ( tags , null , 2 ) } </ pre > ;
77} ;
88
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export interface IPersistenceJoin {
6161 columns : string [ ] ;
6262}
6363
64- export interface IPersistentPaginationPayload < T , U = any > {
64+ export interface IPersistentPaginationPayload < T > {
6565 where ?: WhereCondition < T > ;
6666 joins ?: IPersistenceJoin [ ] ;
6767 orderBy ?: Array < IPersistentOrderBy < T > > ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 toSnakeCase ,
1717} from "./persistence-utils" ;
1818import { removeNullOrUndefinedFromObject } from "@/lib/utils" ;
19+ import { and } from "./persistence-where-operator" ;
1920
2021export class PersistentRepository < DOMAIN_MODEL_TYPE > {
2122 constructor (
@@ -67,6 +68,7 @@ export class PersistentRepository<DOMAIN_MODEL_TYPE> {
6768 payload . columns
6869 ?. map ( ( col ) => `${ this . tableName } .${ col . toString ( ) } ` )
6970 . join ( "," ) ?? `${ this . tableName } .*` ;
71+
7072 const { whereClause, values } = buildWhereClause ( payload . where ) ;
7173 const orderByClause = buildOrderByClause ( payload ?. orderBy ) ;
7274 const { joinConditionClause, joinSelectClause } = buildJoinClause (
Original file line number Diff line number Diff line change 1- import { color } from "@cloudinary/url-gen/qualifiers/background" ;
21import { z } from "zod" ;
32
43export const TagRepositoryInput = {
54 findAllInput : z . object ( {
65 page : z . number ( ) . default ( 1 ) ,
76 limit : z . number ( ) . default ( 10 ) ,
7+ search : z . string ( ) . optional ( ) . nullable ( ) ,
88 } ) ,
99 createInput : z . object ( {
1010 name : z . string ( ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { z } from "zod";
44import { persistenceRepository } from "../persistence-repositories" ;
55import { TagRepositoryInput } from "./inputs/tag.input" ;
66import { handleRepositoryException } from "./RepositoryException" ;
7+ import { like } from "../persistence/persistence-where-operator" ;
78
89export const getTags = async (
910 _input : z . infer < typeof TagRepositoryInput . findAllInput >
@@ -13,6 +14,7 @@ export const getTags = async (
1314 return persistenceRepository . tags . findAllWithPagination ( {
1415 page : input . page ,
1516 limit : input . limit ,
17+ where : input . search ? like ( "name" , `%${ input . search } %` ) : undefined ,
1618 } ) ;
1719 } catch ( error ) {
1820 handleRepositoryException ( error ) ;
You can’t perform that action at this time.
0 commit comments