* Executes a raw query provided through a safe tag function * @see https://github.com/prisma/prisma/issues/7142 * * @param query * @param values * @returns
(query: TemplateStringsArray | Sql, ...values: any[])
| 666 | * @returns |
| 667 | */ |
| 668 | $queryRaw(query: TemplateStringsArray | Sql, ...values: any[]) { |
| 669 | return this._createPrismaPromise((transaction) => { |
| 670 | if ((query as TemplateStringsArray).raw !== undefined || (query as Sql).sql !== undefined) { |
| 671 | return this.$queryRawInternal(transaction, '$queryRaw', ...toSql(query, values)) |
| 672 | } |
| 673 | |
| 674 | throw new PrismaClientValidationError( |
| 675 | `\`$queryRaw\` is a tag function, please use it like the following: |
| 676 | \`\`\` |
| 677 | const result = await prisma.$queryRaw\`SELECT * FROM User WHERE id = \${1} OR email = \${'user@email.com'};\` |
| 678 | \`\`\` |
| 679 | |
| 680 | Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access#queryraw |
| 681 | `, |
| 682 | { clientVersion: this._clientVersion }, |
| 683 | ) |
| 684 | }) |
| 685 | } |
| 686 | |
| 687 | /** |
| 688 | * Counterpart to $queryRaw, that returns strongly typed results |