private <T> BsonDocument encodeEntityForUpsert(T value) {
        Codec<T> codec = (Codec<T>) context.getCodec(value.getClass());
        BsonDocument document = new BsonDocument();
        BsonDocumentWriter writer = new BsonDocumentWriter(document);
        codec.encode(writer, value, UPSERT_ENCODER_CONTEXT);
        return document;
    }
@implNote Send requests to ensure indexes and shard collections synchronously to avoid mongo
          servers throwing "LockBusy" error (error code 46)
turms-server-common/src/main/java/im/turms/server/common/storage/mongo/operation/TurmsMongoOperations.java