$executeRaw method

Future<int> $executeRaw(
  1. String query, {
  2. List parameters = const [],
})

Execute raw SQL.

Example:

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

Implementation

Future<int> $executeRaw(
  String query, {
  List<dynamic> parameters = const [],
}) async {
  final String sdl = GraphQLField(
    'mutation',
    fields: GraphQLFields([
      GraphQLField(
        'queryRaw',
        args: GraphQLArgs([
          GraphQLArg('query', query),
          GraphQLArg('parameters', serializeRawParameters),
        ]),
      )
    ]),
  ).toSdl();

  // Request the query.
  final QueryEngineResult result = await $engine.request(
    query: sdl,
    headers: $headers,
  );

  // return the affected rows.
  return result.data['executeRaw'];
}