raul.sp
raul.sp
CCConvex Community
Created by raul.sp on 10/2/2024 in #support-community
getting random "n" entries from a table with db query
export const getQuestionsWithSession = mutation({ args: {}, handler: async (ctx, _) => { const random_questions = await ctx.db.query("session_question").take(5); // const id = await ctx.db.insert("session_question", { text: "" }); }, }); Lets say this " const random_questions = await ctx.db.query("session_question").take(5); " is where i want to get random 5 entries from table "session_question" . I am sure there are other hacky ways using sort, slice. Is there any convex native way of getting random entries from a table ?
5 replies