createTransient method

Future<void> createTransient(
  1. String name,
  2. String query, {
  3. UserCredentials? userCredentials,
})

Creates a transient projection.

This projection runs until the end of the log and then continues running. Transient projections are not persisted by the server and will be lost 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> createTransient(
  String name,
  String query, {
  UserCredentials? userCredentials,
}) async {
  return $runRequest(() async {
    final client = await $getClient();

    final options = (CreateReq_Options()
      ..transient = (CreateReq_Options_Transient()..name = name)
      ..query = query);

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