| 
									
										
										
										
											2022-09-01 19:26:54 +02:00
										 |  |  | '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; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 19:26:54 +02:00
										 |  |  | module.exports = { | 
					
						
							|  |  |  |   isKnexQuery, | 
					
						
							| 
									
										
										
										
											2022-11-19 00:01:10 +01:00
										 |  |  |   addSchema, | 
					
						
							| 
									
										
										
										
											2022-09-01 19:26:54 +02:00
										 |  |  | }; |