MCPcopy Index your code
hub / github.com/simstudioai/sim / buildCursorCondition

Function buildCursorCondition

apps/sim/lib/logs/list-logs.ts:116–125  ·  view source on GitHub ↗
(sortExpr: unknown, idCol: unknown)

Source from the content-addressed store, hash-verified

114 const orderByClause = (expr: SQL): SQL => sql`${dir(expr)} ${nullsLast}`
115
116 const buildCursorCondition = (sortExpr: unknown, idCol: unknown): SQL | undefined => {
117 if (!cursor) return undefined
118 const v = cursor.v
119 const id = cursor.id
120 const cmp = sortOrder === 'asc' ? sql`>` : sql`<`
121 if (v === null) {
122 return sql`(${sortExpr} IS NULL AND ${idCol} ${cmp} ${id})`
123 }
124 return sql`((${sortExpr} IS NOT NULL AND ${sortExpr} ${cmp} ${v}) OR (${sortExpr} = ${v} AND ${idCol} ${cmp} ${id}) OR ${sortExpr} IS NULL)`
125 }
126
127 const fetchSize = p.limit + 1
128

Callers 1

listLogsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected