On this page本页内容
$multiply
¶Multiplies numbers together and returns the result. 将数字相乘并返回结果。Pass the arguments to 将数组形式的参数传递给$multiply
in an array.$multiply
。
The $multiply
expression has the following syntax:$multiply
表达式的语法如下所示:
The arguments can be any valid expression as long as they resolve to numbers. 参数可以是任何有效的表达式,只要它们解析为数字。For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
Consider a 考虑一个sales
collection with the following documents:sales
集合带有以下文档:
The following aggregation uses the 以下聚合使用$multiply
expression in the $project
pipeline to multiply the price
and the quantity
fields:$project
管道中的$multiply
表达式将价格和数量字段相乘:
The operation returns the following results:操作返回以下结果: