23 lines
605 B
JavaScript
Raw Normal View History

'use strict';
const KnexBuilder = require('knex/lib/query/querybuilder');
const KnexRaw = require('knex/lib/raw');
const isKnexQuery = (value) => {
return value instanceof KnexBuilder || value instanceof KnexRaw;
};
2022-11-19 00:01:10 +01:00
/**
* Adds the name of the schema to the table name if the schema was defined by the user.
* Users can set the db schema only for Postgres in strapi database config.
*/
const addSchema = (tableName) => {
const schemaName = strapi.db.connection.getSchemaName();
return schemaName ? `${schemaName}.${tableName}` : tableName;
};
module.exports = {
isKnexQuery,
2022-11-19 00:01:10 +01:00
addSchema,
};