createContinuous method

Future<void> createContinuous(
  1. String name,
  2. String query, {
  3. bool trackEmittedStreams = false,
  4. UserCredentials? userCredentials,
})

Creates a continuous projection.

This projection runs until the end of the log and then continues running. Continuous projections are persisted by the server and are restarted if the projection subsystem is restarted. The name parameter is used as an identifier for operations on the created projection. The id of the resulting stream is by default \$projections-${name}-result if resultStreamName is not given with the options method in the query,

options({
  resultStreamName: "my_demo_projection_result",
  $includeLinks: false,
  reorderEvents: false,
  processingLag: 0
})
```. The [query] parameter contains
the JavaScript you want created as a one time projection.
Continuous projections have explicit names and you can enable or
disable them via this name. See [user-defined projections API](https://developers.eventstore.com/server/v20.10/docs/projections/user-defined-projections.html#user-defined-projections-api).
for more information about the query language (javascript).

Implementation

Future<void> createContinuous(
  String name,
  String query, {
  bool trackEmittedStreams = false,
  UserCredentials? userCredentials,
}) async {
  return $runRequest(() async {
    final client = await $getClient();

    final options = (CreateReq_Options()
      ..continuous = (CreateReq_Options_Continuous()
        ..name = name
        ..trackEmittedStreams = trackEmittedStreams)
      ..query = query);

    await client.create(
      CreateReq()..options = options,
      options: $getOptions(
        userCredentials: userCredentials,
      ),
    );
  });
}