chore(): improve cart operations + Mikro orm 6.4.16 (#13712)
* chore(): Mikro orm 6.4.16 * Create small-ghosts-draw.md * update config * update config * fix delete * update config * update workflows * order improvements * test pricing quuery * test pricing quuery * configurable connection options * configurable connection options * configurable connection options * Update packages/modules/pricing/src/models/price.ts Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
76bf364440
commit
c54c5ed6de
@@ -98,7 +98,12 @@ export async function mikroOrmCreateConnection(
|
||||
filters: database.filters ?? {},
|
||||
useBatchInserts: true,
|
||||
useBatchUpdates: true,
|
||||
implicitTransactions: false,
|
||||
ignoreUndefinedInQuery: true,
|
||||
batchSize: 100,
|
||||
metadataCache: {
|
||||
enabled: true,
|
||||
},
|
||||
assign: {
|
||||
convertCustomTypes: true,
|
||||
},
|
||||
|
||||
@@ -436,20 +436,23 @@ export function mikroOrmBaseRepositoryFactory<const T extends object>(
|
||||
.getKnexQuery()
|
||||
.toSQL()
|
||||
|
||||
const where = [
|
||||
whereSqlInfo.sql.split("where ")[1],
|
||||
whereSqlInfo.bindings,
|
||||
] as [string, any[]]
|
||||
|
||||
return await (manager.getTransactionContext() ?? manager.getKnex())
|
||||
const builder = (manager.getTransactionContext() ?? manager.getKnex())
|
||||
.queryBuilder()
|
||||
.from(this.tableName)
|
||||
.delete()
|
||||
.where(manager.getKnex().raw(...where))
|
||||
.returning("id")
|
||||
.then((rows: { id: string }[]) => {
|
||||
return rows.map((row: { id: string }) => row.id)
|
||||
})
|
||||
|
||||
const hasWhere = whereSqlInfo.sql.includes("where ")
|
||||
if (hasWhere) {
|
||||
const where = [
|
||||
whereSqlInfo.sql.split("where ")[1],
|
||||
whereSqlInfo.bindings,
|
||||
] as [string, any[]]
|
||||
builder.where(manager.getKnex().raw(...where))
|
||||
}
|
||||
|
||||
return await builder.returning("id").then((rows: { id: string }[]) => {
|
||||
return rows.map((row: { id: string }) => row.id)
|
||||
})
|
||||
}
|
||||
|
||||
async find(
|
||||
|
||||
@@ -13,6 +13,16 @@ export function createPgConnection(options: Options) {
|
||||
options.driverOptions?.ssl ??
|
||||
options.driverOptions?.connection?.ssl ??
|
||||
false
|
||||
const connectionTimeoutMillis =
|
||||
driverOptions?.connectionTimeoutMillis ??
|
||||
driverOptions?.connection?.connectionTimeoutMillis ??
|
||||
5000
|
||||
const keepAliveInitialDelayMillis =
|
||||
driverOptions?.keepAliveInitialDelayMillis ??
|
||||
driverOptions?.connection?.keepAliveInitialDelayMillis ??
|
||||
10000
|
||||
const keepAlive =
|
||||
driverOptions?.keepAlive ?? driverOptions?.connection?.keepAlive ?? true
|
||||
|
||||
return knex<any, any>({
|
||||
client: "pg",
|
||||
@@ -23,11 +33,16 @@ export function createPgConnection(options: Options) {
|
||||
idle_in_transaction_session_timeout:
|
||||
(driverOptions?.idle_in_transaction_session_timeout as number) ??
|
||||
undefined, // prevent null to be passed
|
||||
|
||||
connectionTimeoutMillis: connectionTimeoutMillis as number, // Fail fast on slow connects
|
||||
keepAlive: keepAlive as boolean, // Prevent connections from being dropped
|
||||
keepAliveInitialDelayMillis: keepAliveInitialDelayMillis as number, // Start keepalive probes after 10s
|
||||
},
|
||||
pool: {
|
||||
propagateCreateError: false, // Don't fail entire pool on one bad connection
|
||||
min: (pool?.min as number) ?? 1,
|
||||
// https://knexjs.org/guide/#pool
|
||||
...(pool ?? {}),
|
||||
min: (pool?.min as number) ?? 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user