/** * Sets the bypass document level validation flag. * * @param bypassDocumentValidation If true, allows the write to opt-out of document level validation. * @return this * @mongodb.server.release 3.2 */ public UpdateOptions bypassDocumentValidation(final Boolean bypassDocumentValidation) { options.bypassDocumentValidation(bypassDocumentValidation); return this; }
private WriteResult saveDocument(final DBCollection dbColl, final DBObject document, final InsertOptions options) { if (document.get(ID_FIELD_NAME) == null) { return dbColl.insert(singletonList(document), options.getOptions()); } else { return dbColl.update(new BasicDBObject(ID_FIELD_NAME, document.get(ID_FIELD_NAME)), document, new DBCollectionUpdateOptions() .bypassDocumentValidation(options.getBypassDocumentValidation()) .writeConcern(options.getWriteConcern()) .upsert(true)); } }
/** * Modify an existing document or documents in collection. By default the method updates a single document. The query parameter employs * the same query selectors, as used in {@link DBCollection#find(DBObject)}. * * @param query the selection criteria for the update * @param update the modifications to apply * @param upsert when true, inserts a document if no document matches the update query criteria * @param multi when true, updates all documents in the collection that match the update query criteria, otherwise only updates one * @param concern {@code WriteConcern} to be used during operation * @param bypassDocumentValidation whether to bypass document validation. * @param encoder the DBEncoder to use * @return the result of the operation * @throws com.mongodb.DuplicateKeyException if the write failed to a duplicate unique key * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the update command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/modify-documents/ Modify * @since 2.14 */ public WriteResult update(final DBObject query, final DBObject update, final boolean upsert, final boolean multi, final WriteConcern concern, @Nullable final Boolean bypassDocumentValidation, @Nullable final DBEncoder encoder) { return update(query, update, new DBCollectionUpdateOptions().upsert(upsert).multi(multi) .writeConcern(concern).bypassDocumentValidation(bypassDocumentValidation).encoder(encoder)); }
/** * Sets the bypass document level validation flag. * * @param bypassDocumentValidation If true, allows the write to opt-out of document level validation. * @return this * @mongodb.server.release 3.2 */ public UpdateOptions bypassDocumentValidation(final Boolean bypassDocumentValidation) { options.bypassDocumentValidation(bypassDocumentValidation); return this; }
private WriteResult saveDocument(final DBCollection dbColl, final DBObject document, final InsertOptions options) { if (document.get(ID_FIELD_NAME) == null) { return dbColl.insert(singletonList(document), options.getOptions()); } else { return dbColl.update(new BasicDBObject(ID_FIELD_NAME, document.get(ID_FIELD_NAME)), document, new DBCollectionUpdateOptions() .bypassDocumentValidation(options.getBypassDocumentValidation()) .writeConcern(options.getWriteConcern()) .upsert(true)); } }
/** * Modify an existing document or documents in collection. By default the method updates a single document. The query parameter employs * the same query selectors, as used in {@link DBCollection#find(DBObject)}. * * @param query the selection criteria for the update * @param update the modifications to apply * @param upsert when true, inserts a document if no document matches the update query criteria * @param multi when true, updates all documents in the collection that match the update query criteria, otherwise only updates one * @param concern {@code WriteConcern} to be used during operation * @param bypassDocumentValidation whether to bypass document validation. * @param encoder the DBEncoder to use * @return the result of the operation * @throws com.mongodb.DuplicateKeyException if the write failed to a duplicate unique key * @throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the update command * @throws MongoException if the operation failed for some other reason * @mongodb.driver.manual tutorial/modify-documents/ Modify * @since 2.14 */ public WriteResult update(final DBObject query, final DBObject update, final boolean upsert, final boolean multi, final WriteConcern concern, @Nullable final Boolean bypassDocumentValidation, @Nullable final DBEncoder encoder) { return update(query, update, new DBCollectionUpdateOptions().upsert(upsert).multi(multi) .writeConcern(concern).bypassDocumentValidation(bypassDocumentValidation).encoder(encoder)); }