MCPcopy
hub / github.com/kysely-org/kysely / testKyselyAnyUpdates

Function testKyselyAnyUpdates

test/typings/test-d/kysely-any.test-d.ts:94–137  ·  view source on GitHub ↗
(db: Kysely<any>)

Source from the content-addressed store, hash-verified

92}
93
94async function testKyselyAnyUpdates(db: Kysely<any>) {
95 const r1 = await db
96 .updateTable('foo')
97 .set({ bar: 'baz', spam: 1 })
98 .where('foo.eggs', '=', 1)
99 .executeTakeFirstOrThrow()
100 expectType<UpdateResult>(r1)
101
102 const r2 = await db
103 .updateTable('foo as f')
104 .set({ bar: 'baz', spam: 1 })
105 .where('f.eggs', '=', 1)
106 .where('spam', '=', 2)
107 .executeTakeFirstOrThrow()
108 expectType<UpdateResult>(r2)
109
110 const r3 = await db
111 .updateTable('foo')
112 .set({ bar: 'baz', spam: 1 })
113 .where('foo.eggs', '=', 1)
114 .where('spam', '=', 2)
115 .returning(['a', 'b'])
116 .executeTakeFirstOrThrow()
117 expectType<{ a: any; b: any }>(r3)
118
119 const r4 = await db
120 .updateTable('foo')
121 .set((eb) => ({
122 foo: eb('foo.bar', '=', 1),
123 }))
124 .where('foo.eggs', '=', 1)
125 .executeTakeFirstOrThrow()
126 expectType<UpdateResult>(r4)
127
128 const table: 'foo' | 'bar' = Math.random() > 0.5 ? 'foo' : 'bar'
129 const r5 = await db
130 .updateTable(table)
131 .set((eb) => ({
132 foo: eb('foo.bar', '=', 1),
133 }))
134 .where('foo.eggs', '=', 1)
135 .executeTakeFirstOrThrow()
136 expectType<UpdateResult>(r5)
137}
138
139async function testKyselyAnyDeletes(db: Kysely<any>) {
140 const r1 = await db

Callers

nothing calls this directly

Calls 5

setMethod · 0.80
whereMethod · 0.65
updateTableMethod · 0.65
returningMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…