Jacob Kim
Jacob Kim
CCConvex Community
Created by Jacob Kim on 9/9/2024 in #support-community
neq condition for `withIndex`
here are pseudocodes that fails to compile:
ctx.db
.query('inventory')
.withIndex('by_status', (q) => q.neq('status', 'removed')) // in_stock, sold, removed
ctx.db
.query('inventory')
.withIndex('by_status', (q) => q.neq('status', 'removed')) // in_stock, sold, removed
ctx.db
.query('inventory')
.withIndex('by_status', (q) => q.or(q.eq('status', 'sold'), q.eq('status', 'in_stock')))
ctx.db
.query('inventory')
.withIndex('by_status', (q) => q.or(q.eq('status', 'sold'), q.eq('status', 'in_stock')))
both neq and or are not supported with withIndex() how can I do something like above pseudocode?
19 replies
CCConvex Community
Created by Jacob Kim on 8/7/2024 in #support-community
how to refresh JWTs before they expire
The default jwt.durationMs is an hour and it seems like convex-auth does not automatically refresh jwt. Am I responsible for refreshing the JWT before it expires? Or did I misconfigure something? I am using Next.js, and I am handling auth stuff with middleware like below.
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
isAuthenticatedNextjs,
nextjsMiddlewareRedirect,
convexAuthNextjsToken,
} from '@convex-dev/auth/nextjs/server'

const isSignInPage = createRouteMatcher(['/login'])
const isProtectedRoute = createRouteMatcher(['/app(.*)'])

export default convexAuthNextjsMiddleware((request) => {
if (isSignInPage(request) && isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, '/app')
}

if (isProtectedRoute(request) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, '/login')
}
})

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api)(.*)'],
}
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
isAuthenticatedNextjs,
nextjsMiddlewareRedirect,
convexAuthNextjsToken,
} from '@convex-dev/auth/nextjs/server'

const isSignInPage = createRouteMatcher(['/login'])
const isProtectedRoute = createRouteMatcher(['/app(.*)'])

export default convexAuthNextjsMiddleware((request) => {
if (isSignInPage(request) && isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, '/app')
}

if (isProtectedRoute(request) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, '/login')
}
})

export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api)(.*)'],
}
10 replies