mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 18:28:27 +00:00
feat: switched read db operations to replica nodes
This commit is contained in:
@@ -22,7 +22,7 @@ export const webhookDALFactory = (db: TDbClient) => {
|
||||
|
||||
const find = async (filter: Partial<TWebhooks>, tx?: Knex) => {
|
||||
try {
|
||||
const docs = await webhookFindQuery(tx || db, filter);
|
||||
const docs = await webhookFindQuery(tx || db.replicaNode(), filter);
|
||||
return docs.map(({ envId, envSlug, envName, ...el }) => ({
|
||||
...el,
|
||||
envId,
|
||||
@@ -39,7 +39,7 @@ export const webhookDALFactory = (db: TDbClient) => {
|
||||
|
||||
const findOne = async (filter: Partial<TWebhooks>, tx?: Knex) => {
|
||||
try {
|
||||
const doc = await webhookFindQuery(tx || db, filter).first();
|
||||
const doc = await webhookFindQuery(tx || db.replicaNode(), filter).first();
|
||||
if (!doc) return;
|
||||
|
||||
const { envName: name, envSlug: slug, envId: id, ...el } = doc;
|
||||
@@ -51,7 +51,7 @@ export const webhookDALFactory = (db: TDbClient) => {
|
||||
|
||||
const findById = async (id: string, tx?: Knex) => {
|
||||
try {
|
||||
const doc = await webhookFindQuery(tx || db, {
|
||||
const doc = await webhookFindQuery(tx || db.replicaNode(), {
|
||||
[`${TableName.Webhook}.id` as "id"]: id
|
||||
}).first();
|
||||
if (!doc) return;
|
||||
@@ -65,7 +65,7 @@ export const webhookDALFactory = (db: TDbClient) => {
|
||||
|
||||
const findAllWebhooks = async (projectId: string, environment?: string, secretPath?: string, tx?: Knex) => {
|
||||
try {
|
||||
const webhooks = await (tx || db)(TableName.Webhook)
|
||||
const webhooks = await (tx || db.replicaNode())(TableName.Webhook)
|
||||
.where(`${TableName.Environment}.projectId`, projectId)
|
||||
.where((qb) => {
|
||||
if (environment) {
|
||||
|
||||
Reference in New Issue
Block a user