This commit is contained in:
2025-11-13 06:42:09 +01:00
parent 957709f79d
commit 57e67f5c51
8 changed files with 22 additions and 7 deletions
+8 -2
View File
@@ -1,5 +1,6 @@
import { UserType } from "../types";
import grabDbFullName from "./grab-db-full-name";
import numberfy from "./numberfy";
type Param = {
/**
@@ -8,7 +9,6 @@ type Param = {
dbName?: string;
userId?: string | number;
user?: UserType | null;
nullable?: boolean;
};
/**
@@ -19,7 +19,13 @@ type Param = {
*/
export default function grabDbNames(params?: Param) {
const dbNamePrefix = process.env.DSQL_USER_DB_PREFIX || "datasquirel_user_";
const finalUserId = params?.user?.id || params?.userId;
const finalUserId =
params?.user?.id ||
params?.userId ||
numberfy(process.env.DSQL_USER_ID) ||
numberfy(process.env.DSQL_DB_NAME?.split("_")?.[2]) ||
undefined;
const userDbPrefix = finalUserId
? `${dbNamePrefix}${finalUserId}_`
: undefined;