Created
August 22, 2024 19:48
-
-
Save bmorrisondev/9c3d27517ae3e8e9f12bf41eca29d375 to your computer and use it in GitHub Desktop.
VSCode snippets to quickly generate Convex queries and mutations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"Convex Query": { | |
"prefix": "cvq", | |
"scope": "typescript", | |
"body": [ | |
"export const ${1} = query({", | |
"\targs: {", | |
"\t\t${2}", | |
"\t},", | |
"\thandler: async (ctx, args) => {", | |
"\t\t${0}", | |
"\t}", | |
"})" | |
], | |
"description": "Generate a Convex query" | |
}, | |
"Convex Query with Auth": { | |
"prefix": "cvqa", | |
"scope": "typescript", | |
"body": [ | |
"export const ${1} = query({", | |
"\targs: {", | |
"\t\t${2}", | |
"\t},", | |
"\thandler: async (ctx, args) => {", | |
"\t\tconst auth = await ctx.auth.getUserIdentity()", | |
"\t\tif(!auth) {", | |
"\t\t\t\tthrow new Error(\"Not authorized\")", | |
"\t\t}", | |
"\t\t${0}", | |
"\t}", | |
"})" | |
], | |
"description": "Generate a Convex query and adds a check for auth" | |
}, | |
"Convex Mutation": { | |
"prefix": "cvm", | |
"scope": "typescript", | |
"body": [ | |
"export const ${1} = mutation({", | |
"\targs: {", | |
"\t\t${2}", | |
"\t},", | |
"\thandler: async (ctx, args) => {", | |
"\t\t${0}", | |
"\t}", | |
"})" | |
], | |
"description": "Generate a Convex mutation" | |
}, | |
"Convex Mutation with Auth": { | |
"prefix": "cvma", | |
"scope": "typescript", | |
"body": [ | |
"export const ${1} = mutation({", | |
"\targs: {", | |
"\t\t${2}", | |
"\t},", | |
"\thandler: async (ctx, args) => {", | |
"\t\tconst auth = await ctx.auth.getUserIdentity()", | |
"\t\tif(!auth) {", | |
"\t\t\t\tthrow new Error(\"Not authorized\")", | |
"\t\t}", | |
"\t\t${0}", | |
"\t}", | |
"})" | |
], | |
"description": "Generate a Convex mutation and adds a check for Auth" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment