$executeRaw method

Future $executeRaw(
  1. String query, {
  2. Iterable parameters = const [],
})

Execute raw SQL.

Example:

final int affectedRows = await prisma.$executeRaw('DELETE FROM User');

Implementation

Future<dynamic> $executeRaw(
  String query, {
  Iterable<dynamic> parameters = const [],
}) async {
  final String sdl = GraphQLField(
    'mutation',
    fields: [
      GraphQLField('executeRaw', args: [
        GraphQLArg('query', query),
        GraphQLArg(
            'parameters', json.encode(prismaRawParameter.encode(parameters))),
      ])
    ],
  ).toSdl();

  // Request the query.
  final GraphQLResult result = await _engine.request(
    query: sdl,
    headers: _headers,
    transaction: _transaction,
  );

  return result.data?['executeRaw'];
}