use of com.mongodb.client.model.Updates in project engine by Lumeer.
the class MongoUserNotificationDao method updateNotifications.
@Override
public void updateNotifications(final String searchField, final String searchId, final Map<String, String> updates) {
final List<Bson> sets = updates.entrySet().stream().map(e -> Updates.set(e.getKey(), e.getValue())).collect(Collectors.toList());
final UpdateResult result = databaseCollection().updateMany(Filters.eq(searchField, searchId), Updates.combine(sets));
if (result.getModifiedCount() > 0 && createOrUpdateUserNotificationEvent != null) {
final List<UserNotification> updatedNotifications = databaseCollection().find(Filters.eq(searchField, searchId)).into(new ArrayList<>());
updatedNotifications.forEach(notification -> createOrUpdateUserNotificationEvent.fire(new CreateOrUpdateUserNotification(notification)));
}
}
use of com.mongodb.client.model.Updates in project docs-java by mongodb.
the class Updates method main.
public static void main(String[] args) {
Updates updates = new Updates();
updates.resetCollection(updates);
System.out.println("setUpdate:");
updates.setUpdate();
updates.resetCollection(updates);
System.out.println("unsetUpdate:");
updates.unsetUpdate();
updates.resetCollection(updates);
System.out.println("setOnInsertUpdate:");
updates.setOnInsertUpdate();
updates.resetCollection(updates);
System.out.println("incUpdate:");
updates.incUpdate();
updates.resetCollection(updates);
System.out.println("mulUpdate:");
updates.mulUpdate();
updates.resetCollection(updates);
System.out.println("renameUpdate:");
updates.renameUpdate();
updates.resetCollection(updates);
System.out.println("minUpdate:");
updates.minUpdate();
updates.resetCollection(updates);
System.out.println("maxUpdate:");
updates.maxUpdate();
updates.resetCollection(updates);
System.out.println("currentDateUpdate:");
updates.currentDateUpdate();
updates.resetCollection(updates);
System.out.println("currentTimestampUpdate:");
updates.currentTimestampUpdate();
updates.resetCollection(updates);
System.out.println("bitwiseOrUpdate:");
updates.bitwiseOrUpdate();
updates.resetCollection(updates);
System.out.println("addToSetUpdate:");
updates.addToSetUpdate();
updates.resetCollection(updates);
System.out.println("popFirstUpdate:");
updates.popFirstUpdate();
updates.resetCollection(updates);
System.out.println("pullAllUpdate:");
updates.pullAllUpdate();
updates.resetCollection(updates);
System.out.println("pullUpdate:");
updates.pullUpdate();
updates.resetCollection(updates);
System.out.println("pushUpdate:");
updates.pushUpdate();
updates.resetCollection(updates);
System.out.println("combineUpdate:");
updates.combineUpdate();
updates.resetCollection(updates);
}
Aggregations