Search in sources :

Example 1 with MoveUpdateAction

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

the class UpdateActionTranslator method translateMove.

private static void translateMove(CompositeUpdateAction.Builder builder, BsonDocument argument) throws UpdateException {
    for (Entry<?> entry : argument) {
        Collection<AttributeReference> attRefs = parseAttributeReference(entry.getKey());
        if (!entry.getValue().isString()) {
            throw new UpdateException("The 'to' field for $rename must " + "be a string, but " + entry.getValue() + " were found " + "with key " + entry.getKey());
        }
        AttributeReference newRef = parseAttributReferenceAsObjectReference(entry.getValue().asString().getValue());
        builder.add(new MoveUpdateAction(attRefs, newRef), false);
    }
}
Also used : AttributeReference(com.torodb.core.language.AttributeReference) MoveUpdateAction(com.torodb.mongodb.language.update.MoveUpdateAction) UpdateException(com.torodb.core.exceptions.user.UpdateException)

Aggregations

UpdateException (com.torodb.core.exceptions.user.UpdateException)1 AttributeReference (com.torodb.core.language.AttributeReference)1 MoveUpdateAction (com.torodb.mongodb.language.update.MoveUpdateAction)1