spring-projects / spring-projects/spring-data-mongodb

Consider adding options parameter to ReactiveMongoTemplate.insertAll

Open
#4,252 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Hi folks

Today I faced with need to execute ReactiveMongoTemplate.insertAll with unordered: false parameter since it allows to skip duplicates while inserting (mongo doc). Unfortunately, there is no insertAll with options, however it could be implemented with ReactiveMongoTemplate.execute like this

reactiveMongoTemplate.execute(myCollection) { it ->
            it.insertMany(listOf(), InsertManyOptions().ordered(false))
                .toMono()
                .map { result -> result.insertedIds.size }
        }
            .next()

I don't like this approach since it requires to manually map entity to Document

Could you please consider implementing insertAll with InsertManyOptions parameter in ReactiveMongoTemplate?

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ReactiveMongoTemplate.insertAll API described in the issue, then compare it with the shown ReactiveMongoTemplate.execute and InsertManyOptions usage. Define the requested overload's behavior around ordered inserts and entity-to-document mapping, and verify that insertAll accepts and applies the options.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.