Karlstens
Karlstens
Explore posts from servers
NNuxt
Created by Karlstens on 1/19/2025 in #❓・help
Block an array of dates from Calendar
No description
5 replies
CCConvex Community
Created by Karlstens on 11/5/2023 in #support-community
What tech-stack is used for Convex Docs?
I really like how they all come together, wondering if you're OK to share the tech stack used to achieve such great online docs? https://docs.convex.dev
8 replies
CCConvex Community
Created by Karlstens on 10/27/2023 in #support-community
Script Tag Quick Start - HTML Code mis-match
Hey people - As I work through tutorials to learn Convex, I decided to try Vite with Script Tag Quick Start - but soon I realised that the Convex sample data and the HTML snippet don't line up. The guide leads the user into adding Tasks based sample data to a task DB, whilst the HTML snippet looks to be calling on the other Messages App Convex Example. I was able to figure things out (as I'm not using either for my example/testing), but just a heads up that this tutorial would confuse new users and needs to be updated. Edit: https://docs.convex.dev/quickstart/script-tag
10 replies
CCConvex Community
Created by Karlstens on 10/21/2023 in #support-community
Best practices for Convex, Git and .gitignore
I'm learning how to build a basic website via Vercel, that has simple user inputs that post documents into my Convex DB. As I'm pushing from Dev to Prod via BitBucket, I'm wondering about git best practices after implementing Convex in my project. For example, to kickstart my project I'm using the Vercel Vite template, which works great. As I now implement Convex into the same project, I'm wondering what to be concerned with regarding what I Convex code I push to git (and bear with me 🐻🤗 I'm new to this!) - in that, when I write Convex Functions they sync to Convex Auto-magically, so should I thus not be capturing these functions via git, as they... serve no purpose in my Dev to Prod website push? I had a look on Convex regarding git best practices, but couldn't find much info (or at least haven't found anything yet, still looking).
7 replies
CCConvex Community
Created by Karlstens on 10/15/2023 in #support-community
How do I rebuild a table index after adding documents?
Reading through the documentation, I've read the following;
Similarly, even after an index is defined, Convex will have to do a bit of extra work to keep this index up to date as the data changes. Every time a document is inserted, updated, or deleted in an indexed table, Convex will also update its index entry. This is analogous to a librarian creating new index cards for new books as they add them to the library.
Similarly, even after an index is defined, Convex will have to do a bit of extra work to keep this index up to date as the data changes. Every time a document is inserted, updated, or deleted in an indexed table, Convex will also update its index entry. This is analogous to a librarian creating new index cards for new books as they add them to the library.
So what I've done, is I've created a large amount of documents that are beyond the non-indexed return limit, and have then generated an index for that table. I've then added new data, and am testing out the returns, to find the new data hasn't been indexed yet. New documents returns fine via .take(3), but as far as the index return is concerned - those new documents don't exist. I'd like to understand if it's possible to trigger the manual rebuild of an index, I guess my interval would when approaching an additional ~8000 records to trigger the rebuild - which would allow for either a table look up of new non-indexed records, or an indexed lookup of the previously indexed records. Generally speaking, if index rebuild is automated - how long is the wait before new documents appear in the index?
4 replies
CCConvex Community
Created by Karlstens on 10/15/2023 in #support-community
Miss count of maximum records on Import
No description
1 replies
CCConvex Community
Created by Karlstens on 10/14/2023 in #support-community
Passing Arguments
Hey all, finally found more time to learn Convex. I'm stuck on passing an argument, where for example, I have a table full of email addresses that acts as a whitelist - and I'd like my server to pass an email string to the function, Convex check the email does/doesn't exist, and return true/false. Here's my server app and my functions;
//server.mjs
import { ConvexHttpClient } from "convex/browser";
import { api } from "./convex/_generated/api.js";
import * as dotenv from "dotenv";
dotenv.config({ path: ".env.local" });

const client = new ConvexHttpClient(process.env["CONVEX_URL"]);

client.query(api.whitelistFunctions.get).then(console.log);

client
.query(api.whitelistFunctions.checkEmail, { email: "[email protected]" })
.then(console.log); // This will print true if the email exists, otherwise false
//server.mjs
import { ConvexHttpClient } from "convex/browser";
import { api } from "./convex/_generated/api.js";
import * as dotenv from "dotenv";
dotenv.config({ path: ".env.local" });

const client = new ConvexHttpClient(process.env["CONVEX_URL"]);

client.query(api.whitelistFunctions.get).then(console.log);

client
.query(api.whitelistFunctions.checkEmail, { email: "[email protected]" })
.then(console.log); // This will print true if the email exists, otherwise false
And my whitelistFunctions.js
//whitelistFunctions.js
import { query } from "./_generated/server";
import { v } from "convex/values";

export const get = query({
args: {},
handler: async (ctx) => {
return await ctx.db.query("whitelist").collect();
},
});

export const checkEmail = query({
args: { email: v.string() },

handler: async (ctx) => {
if (!ctx.args.email) {
throw new Error("Email argument is missing or undefined");
}
return await ctx.args.email;
},
});
//whitelistFunctions.js
import { query } from "./_generated/server";
import { v } from "convex/values";

export const get = query({
args: {},
handler: async (ctx) => {
return await ctx.db.query("whitelist").collect();
},
});

export const checkEmail = query({
args: { email: v.string() },

handler: async (ctx) => {
if (!ctx.args.email) {
throw new Error("Email argument is missing or undefined");
}
return await ctx.args.email;
},
});
Get the error
Error: Uncaught TypeError: Cannot read properties of undefined (reading 'email')
at handler (../convex/whitelistFunctions.js:15:13)

at ConvexHttpClient.query (file:///C:/DEV/VS%20Code/Convex/karlstensWebsite/node_modules/convex/dist/esm/browser/http_client.js:122:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Uncaught TypeError: Cannot read properties of undefined (reading 'email')
at handler (../convex/whitelistFunctions.js:15:13)

at ConvexHttpClient.query (file:///C:/DEV/VS%20Code/Convex/karlstensWebsite/node_modules/convex/dist/esm/browser/http_client.js:122:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
*I should note that I started to simplify/hack checkEmail right back to the bone, so that essentially I was just returning the passed argument - but still couldn't figure it out.
18 replies
CCConvex Community
Created by Karlstens on 9/15/2023 in #support-community
Trouble with ESM-style import in Node.js Quickstart
Hello, I'm new to convex and working through the Quickstart documentation. I've run through the steps detailed here - https://docs.convex.dev/quickstart/nodejs but unfortunately am after running through all the steps. My environment is VS Code, BASH terminal and Node.JS 20.6. Upon running the final script.js I get this return.
$ node script.js
C:\DEV\VS Code\Convex\my-project\convex\_generated\api.js:12
import { anyApi } from "convex/server";
^^^^^^

SyntaxError: Cannot use import statement outside a module
$ node script.js
C:\DEV\VS Code\Convex\my-project\convex\_generated\api.js:12
import { anyApi } from "convex/server";
^^^^^^

SyntaxError: Cannot use import statement outside a module
Unfortunately this is very deep-end-of-the-pool for me, but just giving my feedback as my first experience to following the quick-start that I'm essentially stuck.
11 replies