Mongodb 3.2新的特性

原文地址:https://docs.mongodb.com/manual/release-notes/3.2/

New Aggregation Stages

Stage Description Syntax
$sample Randomly selects N documents from its input. { $sample: { size: <positive integer> } }
$indexStats Returns statistics on index usage. { $indexStats: { } }
$lookup Performs a left outer join with another collection.
{
   $lookup:
     {
       from: <collection to join>,
       localField: <fieldA>,
       foreignField: <fieldB>,
       as: <output array field>
     }
}

New Accumulators(累加器) for $group Stage

Accumulator Description Syntax
$stdDevSamp Calculates standard deviation. { $stdDevSamp: <array> }
$stdDevPop Calculates population standard deviation. { $stdDevPop: <array> }

New Aggregation Arithmetic Operators

Operator Description Syntax
$sqrt Calculates the square root. { $sqrt: <number> }
$abs Returns the absolute value of a number. { $abs: <number> }
$log Calculates the log of a number in the specified base. { $log: [ <number>, <base> ] }
$log10 Calculates the log base 10 of a number. { $log10: <number> }
$ln Calculates the natural log of a number. { $ln: <number> }
$pow Raises a number to the specified exponent(指数). { $pow: [ <number>, <exponent> ] }
$exp Raises e to the specified exponent. { exp: <number> }
$trunc Truncates(截取) a number to its integer. { $trunc: <number> }
$ceil Returns the smallest integer greater than or equal to the specified number. { $ceil: <number> }
$floor Returns the largest integer less than or equal to the specified number. { floor: <number> }

New Aggregation Array Operators

Operator Description Syntax
$slice Returns a subset of an array.

{ $slice: [ <array>, <n> ] }

or

{ $slice: [ <array>, <position>, <n> ] }

$arrayElemAt Returns the element at the specified array index. { $arrayElemAt: [ <array>, <idx> ] }
$concatArrays Concatenates(串联) arrays.
{
  $concatArrays: [ <array1>, <array2>, ... ]
}
$isArray Determines if the operand is an array. { $isArray: [ <expression> ] }
$filter Selects a subset of the array based on the condition.
{
  $filter:
    {
      input: <array>,
      as: <string>,
      cond: <expression>
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值