Search in sources :

Example 1 with IncrementUpdateAction

use of com.torodb.mongodb.language.update.IncrementUpdateAction in project torodb by torodb.

the class UpdateActionTranslator method translateIncrement.

private static void translateIncrement(CompositeUpdateAction.Builder builder, BsonDocument argument) throws UpdateException {
    for (Entry<?> entry : argument) {
        Collection<AttributeReference> attRefs = parseAttributeReference(entry.getKey());
        KvValue<?> translatedValue = MongoWpConverter.translate(entry.getValue());
        if (!(translatedValue instanceof KvNumeric)) {
            throw new UpdateException("Cannot increment with a " + "non-numeric argument");
        }
        builder.add(new IncrementUpdateAction(attRefs, (KvNumeric<?>) translatedValue), false);
    }
}
Also used : KvNumeric(com.torodb.kvdocument.values.KvNumeric) AttributeReference(com.torodb.core.language.AttributeReference) IncrementUpdateAction(com.torodb.mongodb.language.update.IncrementUpdateAction) UpdateException(com.torodb.core.exceptions.user.UpdateException)

Aggregations

UpdateException (com.torodb.core.exceptions.user.UpdateException)1 AttributeReference (com.torodb.core.language.AttributeReference)1 KvNumeric (com.torodb.kvdocument.values.KvNumeric)1 IncrementUpdateAction (com.torodb.mongodb.language.update.IncrementUpdateAction)1