async upsert(request) {
    const id = request.getId();
    const content = request.getBodyObject("changes");
    const defaultValues = request.getBodyObject("default", {});
    const userId = request.getKuid();
    const silent = request.getBoolean("silent");
    const refresh = request.getString("refresh", "false");
    const retryOnConflict = request.input.args.retryOnConflict;
    const source = request.getBoolean("source");
    const { index, collection } = request.getIndexAndCollection();

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

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

    if (!silent && updatedDocument.created) {
      await this.ask(
        "core:realtime:document:notify",
        request,
        actionEnum.CREATE,
        updatedDocument._source,
      );
    } else if (!silent) {
      const _updatedFields = extractFields(content, {
        fieldsToIgnore: ["_kuzzle_info"],
      });

      await this.ask(
        "core:realtime:document:notify",
        request,
        actionEnum.UPDATE,
        {
          _id: updatedDocument._id,
          _source: updatedDocument._source,
          _updatedFields,
        },
      );
    }

    if (source) {
      return updatedDocument;
    }

    return {
      _id: updatedDocument._id,
      _version: updatedDocument._version,
      created: updatedDocument.created,
    };
  }
Applies a partial update to an existing document.
If the document doesn't already exist, a new document is created.

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