com.mongodb.client.model.InsertOneOptions Java Examples
The following examples show how to use
com.mongodb.client.model.InsertOneOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicInteractionTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test void testDocumentInsertionWithOptions() { List<Integer> books = Arrays.asList(27464, 747854); DBObject person = new BasicDBObject("_id", "jo") .append("name", "Jo Bloggs") .append("address", new BasicDBObject("street", "123 Fake St") .append("city", "Faketon") .append("state", "MA") .append("zip", 12345)) .append("books", books); ReactiveMongoDatabase database = client.getDatabase(DATABASE); ReactiveMongoCollection<DBObject> collection = database.getCollection(randomAlphaString(8), DBObject.class); collection.insertOne(person, new InsertOneOptions().bypassDocumentValidation(true)).await().indefinitely(); Optional<DBObject> maybe = collection.find().collectItems().first().await().asOptional().indefinitely(); assertThat(maybe).isNotEmpty().containsInstanceOf(DBObject.class) .hasValueSatisfying(obj -> assertThat(obj.get("name")).isEqualTo("Jo Bloggs")); }
Example #2
Source File: MongoRyaInstanceDetailsRepository.java From rya with Apache License 2.0 | 6 votes |
@Override public void initialize(final RyaDetails details) throws AlreadyInitializedException, RyaDetailsRepositoryException { // Preconditions. requireNonNull( details ); if(!details.getRyaInstanceName().equals( instanceName )) { throw new RyaDetailsRepositoryException("The instance name that was in the provided 'details' does not match " + "the instance name that this repository is connected to. Make sure you're connected to the" + "correct Rya instance."); } if(isInitialized()) { throw new AlreadyInitializedException("The repository has already been initialized for the Rya instance named '" + instanceName + "'."); } // Create the document that hosts the details if it has not been created yet. db.createCollection(INSTANCE_DETAILS_COLLECTION_NAME, new CreateCollectionOptions()); final MongoCollection<Document> col = db.getCollection(INSTANCE_DETAILS_COLLECTION_NAME); // Write the details to the collection. col.insertOne(MongoDetailsAdapter.toDocument(details), new InsertOneOptions()); }
Example #3
Source File: MongoCollectionImpl.java From mongo-java-driver-rx with Apache License 2.0 | 5 votes |
@Override public Observable<Success> insertOne(final TDocument document, final InsertOneOptions options) { return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Success>>() { @Override public void apply(final SingleResultCallback<Success> callback) { wrapped.insertOne(document, options, voidToSuccessCallback(callback)); } }), observableAdapter); }
Example #4
Source File: MongoCollectionImpl.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 5 votes |
@Override public Publisher<Success> insertOne(final TDocument document, final InsertOneOptions options) { return new ObservableToPublisher<Success>(com.mongodb.async.client.Observables.observe( new Block<com.mongodb.async.SingleResultCallback<Success>>() { @Override public void apply(final com.mongodb.async.SingleResultCallback<Success> callback) { wrapped.insertOne(document, options, voidToSuccessCallback(callback)); } })); }
Example #5
Source File: MongoCollectionImpl.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 5 votes |
@Override public Publisher<Success> insertOne(final ClientSession clientSession, final TDocument document, final InsertOneOptions options) { return new ObservableToPublisher<Success>(com.mongodb.async.client.Observables.observe( new Block<com.mongodb.async.SingleResultCallback<Success>>() { @Override public void apply(final com.mongodb.async.SingleResultCallback<Success> callback) { wrapped.insertOne(clientSession.getWrapped(), document, options, voidToSuccessCallback(callback)); } })); }
Example #6
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(T t, InsertOneOptions options) { return Wrappers.toUni(collection.insertOne(t, options)); }
Example #7
Source File: ReactiveMongoCollectionImpl.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Uni<InsertOneResult> insertOne(ClientSession clientSession, T t, InsertOneOptions options) { return Wrappers.toUni(collection.insertOne(clientSession, t, options)); }
Example #8
Source File: MongoCollectionImpl.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 4 votes |
@Override public Publisher<Success> insertOne(final TDocument document) { return insertOne(document, new InsertOneOptions()); }
Example #9
Source File: MongoCollectionImpl.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 4 votes |
@Override public Publisher<Success> insertOne(final ClientSession clientSession, final TDocument document) { return insertOne(clientSession, document, new InsertOneOptions()); }
Example #10
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * Inserts the provided document. If the document is missing an identifier, the driver should generate one. * * @param document the document to insert * @param options the options to apply to the operation * @return a {@link Uni} completed successfully when the operation completes, or propagating a * {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure. */ Uni<InsertOneResult> insertOne(T document, InsertOneOptions options);
Example #11
Source File: ReactiveMongoCollection.java From quarkus with Apache License 2.0 | 2 votes |
/** * Inserts the provided document. If the document is missing an identifier, the driver should generate one. * * @param clientSession the client session with which to associate this operation * @param document the document to insert * @param options the options to apply to the operation * @return a {@link Uni} completed successfully when the operation completes, or propagating a * {@link com.mongodb.DuplicateKeyException} or {@link com.mongodb.MongoException} on failure. */ Uni<InsertOneResult> insertOne(ClientSession clientSession, T document, InsertOneOptions options);
Example #12
Source File: MongoCollection.java From mongo-java-driver-rx with Apache License 2.0 | 2 votes |
/** * Inserts the provided document. If the document is missing an identifier, the driver should generate one. * * @param document the document to insert * @param options the options to apply to the operation * @return an Observable with a single element indicating when the operation has completed or with either a * com.mongodb.DuplicateKeyException or com.mongodb.MongoException * @since 1.2 */ Observable<Success> insertOne(TDocument document, InsertOneOptions options);
Example #13
Source File: MongoCollection.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 2 votes |
/** * Inserts the provided document. If the document is missing an identifier, the driver should generate one. * * @param document the document to insert * @param options the options to apply to the operation * @return a publisher with a single element indicating when the operation has completed or with either a * com.mongodb.DuplicateKeyException or com.mongodb.MongoException * @since 1.2 */ Publisher<Success> insertOne(TDocument document, InsertOneOptions options);
Example #14
Source File: MongoCollection.java From mongo-java-driver-reactivestreams with Apache License 2.0 | 2 votes |
/** * Inserts the provided document. If the document is missing an identifier, the driver should generate one. * * @param clientSession the client session with which to associate this operation * @param document the document to insert * @param options the options to apply to the operation * @return a publisher with a single element indicating when the operation has completed or with either a * com.mongodb.DuplicateKeyException or com.mongodb.MongoException * @mongodb.server.release 3.6 * @since 1.7 */ Publisher<Success> insertOne(ClientSession clientSession, TDocument document, InsertOneOptions options);