@@ -25,7 +25,7 @@ function addExcerpts<T extends Article>(articles: T[]): (T & { excerpt: string }
2525 return articles . map ( ( a ) => ( { ...a , excerpt : generateExcerpt ( a . content ) } ) ) ;
2626}
2727
28- export async function listPublishedArticles ( limit = 100 ) {
28+ export async function listPublishedArticles ( limit : number ) {
2929 const articles = await db . query . article . findMany ( {
3030 where : eq ( article . published , true ) ,
3131 orderBy : desc ( article . publishedAt ) ,
@@ -66,7 +66,7 @@ export async function getPublishedArticle(slug: string) {
6666 return result ? addExcerpt ( result ) : null ;
6767}
6868
69- export async function listAllArticles ( limit = 1000 ) {
69+ export async function listAllArticles ( limit : number ) {
7070 const articles = await db . query . article . findMany ( {
7171 orderBy : desc ( article . createdAt ) ,
7272 limit,
@@ -75,9 +75,9 @@ export async function listAllArticles(limit = 1000) {
7575 return addExcerpts ( articles ) ;
7676}
7777
78- export async function getArticleById ( id : string ) {
78+ export async function getArticleById ( articleId : string ) {
7979 const result = await db . query . article . findFirst ( {
80- where : eq ( article . id , id ) ,
80+ where : eq ( article . id , articleId ) ,
8181 with : { author : true } ,
8282 } ) ;
8383 return result ? addExcerpt ( result ) : null ;
@@ -89,26 +89,26 @@ export async function createArticle(data: NewArticle) {
8989 return created ;
9090}
9191
92- export async function updateArticle ( id : string , data : Partial < Omit < NewArticle , "id" > > ) {
92+ export async function updateArticle ( articleId : string , data : Partial < Omit < NewArticle , "id" > > ) {
9393 const [ updated ] = await db
9494 . update ( article )
9595 . set ( { ...data , updatedAt : new Date ( ) } )
96- . where ( eq ( article . id , id ) )
96+ . where ( eq ( article . id , articleId ) )
9797 . returning ( ) ;
9898 if ( ! updated ) throw new Error ( "Failed to update article" ) ;
9999 return updated ;
100100}
101101
102- export async function deleteArticle ( id : string ) {
103- await db . delete ( article ) . where ( eq ( article . id , id ) ) ;
102+ export async function deleteArticle ( articleId : string ) {
103+ await db . delete ( article ) . where ( eq ( article . id , articleId ) ) ;
104104}
105105
106- export async function publishArticle ( id : string ) {
107- return updateArticle ( id , { published : true , publishedAt : new Date ( ) } ) ;
106+ export async function publishArticle ( articleId : string ) {
107+ return updateArticle ( articleId , { published : true , publishedAt : new Date ( ) } ) ;
108108}
109109
110- export async function unpublishArticle ( id : string ) {
111- return updateArticle ( id , { published : false , publishedAt : null } ) ;
110+ export async function unpublishArticle ( articleId : string ) {
111+ return updateArticle ( articleId , { published : false , publishedAt : null } ) ;
112112}
113113
114114export async function getRelatedArticles (
@@ -152,7 +152,7 @@ export async function getRelatedArticles(
152152 return addExcerpts ( sameAuthorArticles ) ;
153153}
154154
155- export async function searchPublishedArticles ( query : string , limit = 50 ) {
155+ export async function searchPublishedArticles ( query : string , limit : number ) {
156156 const searchPattern = createSearchPattern ( query ) ;
157157 if ( ! searchPattern ) {
158158 return [ ] ;
@@ -170,7 +170,7 @@ export async function searchPublishedArticles(query: string, limit = 50) {
170170 return addExcerpts ( articles ) ;
171171}
172172
173- export async function searchAllArticles ( query : string , limit = 100 ) {
173+ export async function searchAllArticles ( query : string , limit : number ) {
174174 const searchPattern = createSearchPattern ( query ) ;
175175 if ( ! searchPattern ) {
176176 return [ ] ;
@@ -215,7 +215,7 @@ export async function getRecentDraftArticles(limit: number) {
215215 return addExcerpts ( articles ) ;
216216}
217217
218- export async function listDraftArticles ( limit = 1000 ) {
218+ export async function listDraftArticles ( limit : number ) {
219219 const articles = await db . query . article . findMany ( {
220220 where : eq ( article . published , false ) ,
221221 orderBy : desc ( article . updatedAt ) ,
0 commit comments