<filename>rxmicro-annotation-processor-data-mongo/src/test/resources/output/io.rxmicro.examples.data.mongo.supported.types/$$MongoInsertDataRepository.java
package io.rxmicro.examples.data.mongo.supported.types;

import com.mongodb.reactivestreams.client.MongoDatabase;
import io.rxmicro.data.mongo.detail.AbstractMongoRepository;
import io.rxmicro.examples.data.mongo.supported.types.model.$$SupportedTypesEntityEntityToMongoDBConverter;
import io.rxmicro.examples.data.mongo.supported.types.model.SupportedTypesEntity;
import org.bson.Document;
import reactor.core.publisher.Mono;

/**
 * Generated by {@code RxMicro Annotation Processor}
 */
public final class $$MongoInsertDataRepository extends AbstractMongoRepository implements InsertDataRepository {

    private final $$SupportedTypesEntityEntityToMongoDBConverter supportedTypesEntityEntityToMongoDBConverter =
            new $$SupportedTypesEntityEntityToMongoDBConverter();

    public $$MongoInsertDataRepository(final MongoDatabase mongoDatabase) {
        super(InsertDataRepository.class, mongoDatabase.getCollection("supportedTypes"));
    }

    @Override
    public Mono<SupportedTypesEntity> insert(final SupportedTypesEntity supportedTypesEntity) {
        final Document document = supportedTypesEntityEntityToMongoDBConverter.toDB(supportedTypesEntity, true);
        return Mono.from(collection.insertOne(document))
                .map(result -> supportedTypesEntity)
                .doOnSuccess(a -> supportedTypesEntityEntityToMongoDBConverter.setId(document, supportedTypesEntity));
    }
}
