mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			605 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			605 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| '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;
 | |
| };
 | |
| 
 | |
| /**
 | |
|  * 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,
 | |
|   addSchema,
 | |
| };
 | 
