Fix bigint/number type in orm WHERE
This commit is contained in:
parent
818311bcb4
commit
607fd3808a
3 changed files with 3 additions and 3 deletions
1
db/orm-defs.d.ts
vendored
1
db/orm-defs.d.ts
vendored
|
@ -114,3 +114,4 @@ export type AllKeys<U> = U extends any ? keyof U : never
|
||||||
export type PickTypeOf<T, K extends AllKeys<T>> = T extends { [k in K]?: any } ? T[K] : never
|
export type PickTypeOf<T, K extends AllKeys<T>> = T extends { [k in K]?: any } ? T[K] : never
|
||||||
export type Merge<U> = {[x in AllKeys<U>]: PickTypeOf<U, x>}
|
export type Merge<U> = {[x in AllKeys<U>]: PickTypeOf<U, x>}
|
||||||
export type Nullable<T> = {[k in keyof T]: T[k] | null}
|
export type Nullable<T> = {[k in keyof T]: T[k] | null}
|
||||||
|
export type Numberish<T> = {[k in keyof T]: T[k] extends number ? (number | bigint) : T[k]}
|
||||||
|
|
|
@ -8,7 +8,7 @@ const U = require("./orm-defs")
|
||||||
* @template {keyof U.Models[Table]} Col
|
* @template {keyof U.Models[Table]} Col
|
||||||
* @param {Table} table
|
* @param {Table} table
|
||||||
* @param {Col[] | Col} cols
|
* @param {Col[] | Col} cols
|
||||||
* @param {Partial<U.Models[Table]>} where
|
* @param {Partial<U.Numberish<U.Models[Table]>>} where
|
||||||
* @param {string} [e]
|
* @param {string} [e]
|
||||||
*/
|
*/
|
||||||
function select(table, cols, where = {}, e = "") {
|
function select(table, cols, where = {}, e = "") {
|
||||||
|
@ -108,7 +108,7 @@ class From {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Partial<U.Models[Table]>} conditions
|
* @param {Partial<U.Numberish<U.Models[Table]>>} conditions
|
||||||
*/
|
*/
|
||||||
where(conditions) {
|
where(conditions) {
|
||||||
const wheres = Object.entries(conditions).map(([col, value]) => {
|
const wheres = Object.entries(conditions).map(([col, value]) => {
|
||||||
|
|
|
@ -25,7 +25,6 @@ async function deleteMessage(event) {
|
||||||
*/
|
*/
|
||||||
async function removeReaction(event) {
|
async function removeReaction(event) {
|
||||||
const hash = utils.getEventIDHash(event.redacts)
|
const hash = utils.getEventIDHash(event.redacts)
|
||||||
// TODO: this works but fix the type
|
|
||||||
const row = from("reaction").join("message_channel", "message_id").select("channel_id", "message_id", "encoded_emoji").where({hashed_event_id: hash}).get()
|
const row = from("reaction").join("message_channel", "message_id").select("channel_id", "message_id", "encoded_emoji").where({hashed_event_id: hash}).get()
|
||||||
if (!row) return
|
if (!row) return
|
||||||
await discord.snow.channel.deleteReactionSelf(row.channel_id, row.message_id, row.encoded_emoji)
|
await discord.snow.channel.deleteReactionSelf(row.channel_id, row.message_id, row.encoded_emoji)
|
||||||
|
|
Loading…
Reference in a new issue