Frank
Frank
CCConvex Community
Created by Frank on 12/2/2024 in #support-community
Is there a way to infer "union of column name literals" from a table schema?
Hi! When implementing a query that accepts sortBy as an arg, I'm specifying it to be a string.
args: {
sortBy: v.optional(v.string()),
sortOrder: v.optional(v.union(v.literal("asc"), v.literal("desc"))),
},
args: {
sortBy: v.optional(v.string()),
sortOrder: v.optional(v.union(v.literal("asc"), v.literal("desc"))),
},
I want to enforce sortBy here to be one of the column names of a table, but ideally don't want to hardcode the column name literals here. I wonder Is there a way to infer "union of column name literals" from a table schema? Appreciate any thoughts on this!
4 replies
CCConvex Community
Created by Frank on 11/27/2024 in #support-community
[storage] Is it possible to reference file url instead of storage id in a table?
Hi, I've just started trying out Convex file storage. The documentation uses a chat app example (https://docs.convex.dev/file-storage/serve-files#generating-file-url-in-queries): 1. If the message is an image, it's message.body is a storage id 2. when retrieving that message, the convex function uses await ctx.storage.getUrl(message.body) to convert storage id to file url I observed that 1. the storage id is something like kg25kw... and the file url is something like https://<project-id>.convex.cloud/api/storage/ce47fad6-xxxx 2. storage id to file url seems to be a one-to-one mapping The might be a dumb question but: - I wonder when creating the message, is it possible to directly store the file url, instead of the storage id? - In that case I assume when retrieving that message, we can save a network call ctx.storage.getUrl() Appreciate any thoughts on this 🙏
6 replies