"Correct" way to create a unique index with some raw SQL
username
column, but I want it to be unique on LOWER(username)
. I have the following, and it works, but I was wondering if there is an alternative way to do this without having it all as a raw query?
``
await sql
CREATE UNIQUE INDEX users_unique_username_idx ON users (LOWER(username));`.execute(
db,...TS2345: Argument of type "id" is not assignable to parameter of type ReferenceExpression<Database
Join + Nested Object
lodges
and lodge_conditions
. I just wanna make a query such that I'll get back something of the type
```typescript
Selectable<LodgesTable> & { conditions: Selectable<LodgeConditionsTable> }...conditions_id
and JSON object as columns and join with it on conditions_id
and select just the JSON object column....Arbitrary insert statement
sql.parameter
function, but I don't see anything like that in the docs.sql
tag.
sql`insert into foo (id) values (${id})`.execute(db)
sql`insert into foo (id) values (${id})`.execute(db)
How to handle versioning of database objects.
Sqlite JSON
stringify
and parse
JSON myself when using Kysely, but it looks like I can addColumn("myColumn", "json")
. However, when I try to insert values as JSON, I get TypeError: SQLite3 can only bind numbers, strings, bigints, buffers, and null
.
If I strigify
my JSON first, it adds to the database properly, but the Kysely gives me type errors. Should I have my Database
table column of type string
when I am passing type "json" to Kysely?...case() return boolean (castTo doesn't work?)
TINYINT convert to bool
CASE with subquery clause
{ name: string }
:
```ts
eb.case()
.when('re.type', '=', 'company')...Ad hoc custom column type
Creating a table within a schema using a column from a table in another schema
Guidance to create a generic wrapper over Kysely
Kysely
instance, a database table name and an array of column names.
- The function will return an authenticator instance you can use to perform user lookups during Login. The internals of this function are not important for this discussion.
...Any way to docutype a Column as `@deprecated`?
@deprecated
type identifier in the Table type definition comments to be used in queries, is there a way to make it work with Kysely?Help with CTE query
Error this query cannot be compiled to SQL
``
await trx.executeQuery(
sql<any>
ALTER SCHEMA ${current.subdomain} RENAME TO ${subdomain};`...``ts
await sql
.raw(
ALTER SCHEMA "${current.subdomain}" RENAME TO "${subdomain}"`)
.execute(trx)...Object literal may only specify known properties, and 'clientId' does not exist in type 'InsertObjec
Reuse subquery selects
myUnion().as('u')
Use JSON key as text
->
to ->>
, doh!Typing issue when working with onConflict
Json
to string
. This is something Kysely should handle, but it's really difficult in that case. What I'd do is this
```ts
export type Json = ColumnType<
JsonValue,...