1+ import { v } from "convex/values" ;
12import { mutation , query } from "./_generated/server" ;
23
3- export const get = query (
4- async ( { db } , { counterName } : { counterName : string } ) : Promise < number > => {
4+ export const get = query ( {
5+ args : {
6+ counterName : v . string ( ) ,
7+ } ,
8+ handler : async ( { db } , { counterName } ) : Promise < number > => {
59 const counterDoc = await db
610 . query ( "counter_table" )
711 . filter ( ( q ) => q . eq ( q . field ( "name" ) , counterName ) )
@@ -12,13 +16,14 @@ export const get = query(
1216 }
1317 return counterDoc . counter ;
1418 } ,
15- ) ;
19+ } ) ;
1620
17- export const increment = mutation (
18- async (
19- { db, auth } ,
20- { counterName, increment } : { counterName : string ; increment : number } ,
21- ) => {
21+ export const increment = mutation ( {
22+ args : {
23+ counterName : v . string ( ) ,
24+ increment : v . number ( ) ,
25+ } ,
26+ handler : async ( { db, auth } , { counterName, increment } ) => {
2227 const identity = await auth . getUserIdentity ( ) ;
2328 if ( ! identity ) {
2429 throw new Error ( "Unauthenticated call to incrementCounter" ) ;
@@ -40,4 +45,4 @@ export const increment = mutation(
4045 console . log ( `Value of counter is now ${ counterDoc . counter } .` ) ;
4146 }
4247 } ,
43- ) ;
48+ } ) ;
0 commit comments