Mongodb 3.2新的特性

来源:互联网 发布:mac怎么强制删除软件 编辑:程序博客网 时间:2024/06/06 00:21
原文地址:https://docs.mongodb.com/manual/release-notes/3.2/

New Aggregation Stages

StageDescriptionSyntax$sampleRandomly selects N documents from its input.{ $sample: { size: <positive integer> } }$indexStatsReturns statistics on index usage.{ $indexStats: { } }$lookupPerforms 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

AccumulatorDescriptionSyntax$stdDevSampCalculates standard deviation.{ $stdDevSamp: <array> }$stdDevPopCalculates population standard deviation.{ $stdDevPop: <array> }

New Aggregation Arithmetic Operators

OperatorDescriptionSyntax$sqrtCalculates the square root.{ $sqrt: <number> }$absReturns the absolute value of a number.{ $abs: <number> }$logCalculates the log of a number in the specified base.{ $log: [ <number>, <base> ] }$log10Calculates the log base 10 of a number.{ $log10: <number> }$lnCalculates the natural log of a number.{ $ln: <number> }$powRaises a number to the specified exponent(指数).{ $pow: [ <number>, <exponent> ] }$expRaises e to the specified exponent.{ exp: <number> }$truncTruncates(截取) a number to its integer.{ $trunc: <number> }$ceilReturns the smallest integer greater than or equal to the specified number.{ $ceil: <number> }$floorReturns the largest integer less than or equal to the specified number.{ floor: <number> }

New Aggregation Array Operators

OperatorDescriptionSyntax$sliceReturns a subset of an array.

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

or

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

$arrayElemAtReturns the element at the specified array index.{ $arrayElemAt: [ <array>, <idx> ] }$concatArraysConcatenates(串联) arrays.
{  $concatArrays: [ <array1>, <array2>, ... ]}
$isArrayDetermines if the operand is an array.{ $isArray: [ <expression> ] }$filterSelects a subset of the array based on the condition.
{  $filter:    {      input: <array>,      as: <string>,      cond: <expression>    }}
0 0
原创粉丝点击