You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
com.mongodb.MongoCommandException: Command failed with error 18629: '$dateToString only supports an object as its argument' on server localhost:27018. The full response is { "ok" : 0.0, "errmsg" : "$dateToString only supports an object as its argument", "code" : 18629 }
at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:86)
at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:119)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159)
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286)
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112)
at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:227)
at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:223)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212)
at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:223)
at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:65)
at com.mongodb.Mongo.execute(Mongo.java:773)
at com.mongodb.Mongo$2.execute(Mongo.java:760)
at com.mongodb.DBCollection.aggregate(DBCollection.java:1377)
at com.mongodb.DBCollection.aggregate(DBCollection.java:1347)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:230)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:222)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:212)
The text was updated successfully, but these errors were encountered:
There's no way currently to use $dateToString aggregation operator.
Projection.expression wraps all arguments as a list while dateToString expects a single object as argument.
I have tried all 3 examples bellow and all of them fail with the same exception:
DBObject format = new BasicDBObject("format", "%Y-%m-%d");
format.put("date", "$t");
Object format = new Object(){
public String format = "%Y-%m-%d";
public String date = "$t";
};
Object format = "{"format": "%Y-%m-%d", "date": "$t"}";
...
.project(projection("t", expression("$dateToString", format)))
Results in:
com.mongodb.MongoCommandException: Command failed with error 18629: '$dateToString only supports an object as its argument' on server localhost:27018. The full response is { "ok" : 0.0, "errmsg" : "$dateToString only supports an object as its argument", "code" : 18629 }
at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:86)
at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:119)
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159)
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286)
at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112)
at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:227)
at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:223)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212)
at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:223)
at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:65)
at com.mongodb.Mongo.execute(Mongo.java:773)
at com.mongodb.Mongo$2.execute(Mongo.java:760)
at com.mongodb.DBCollection.aggregate(DBCollection.java:1377)
at com.mongodb.DBCollection.aggregate(DBCollection.java:1347)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:230)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:222)
at org.mongodb.morphia.aggregation.AggregationPipelineImpl.aggregate(AggregationPipelineImpl.java:212)
The text was updated successfully, but these errors were encountered: