async createOrReplace(request) {
    const id = request.getId();
    const content = request.getBody();
    const userId = request.getKuid();
    const silent = request.getBoolean("silent");
    const refresh = request.getString("refresh", "false");
    const { index, collection } = request.getIndexAndCollection();

    const modifiedRequest = await global.kuzzle.validation.validate(
      request,
      false,
    );

    // Add metadata
    const pipeMetadataResult = await this.pipe(
      "generic:document:injectMetadata",
      {
        metadata: {
          author: userId,
          createdAt: Date.now(),
          updatedAt: Date.now(),
          updater: userId,
        },
        request,
      },
    );

    const response = await this.ask(
      "core:storage:public:document:createOrReplace",
      index,
      collection,
      id,
      {
        ...content,
        _kuzzle_info: pipeMetadataResult.metadata,
      },
      {
        injectKuzzleMeta: false,
        refresh,
        userId,
      },
    );

    if (!silent) {
      await this.ask(
        "core:realtime:document:notify",
        modifiedRequest,
        actionEnum.WRITE,
        response,
      );
    }

    return response;
  }
Create a new document through the persistent layer. If it already exists, update it instead.

@param {Request} request
@returns {Promise<Object>}