发布于 2015-09-14 15:13:11 | 70 次阅读 | 评论: 0 | 来源: 网络整理

_hashBSONElement

2.3.2 新版功能.

_hashBSONElement is an internal command that computes the MD5 hash of a BSON element. Eight (8) bytes are returned from the 16 byte MD5 hash.

参数:
  • key (BSONElement) – specifies the BSON element to hash.
  • seed (integer) – specifies a seed to use to compute the hash.
返回:

A document consisting of key, seed, out and ok fields.

Fields:
  • key (BSONType) – the original BSON element.
  • seed (integer) – the seed used for the hash, defaults to 0.
  • out (NumberLong) – the decimal result of the hash.
  • ok (integer) – exit code (1 = ok, 0 = error)

注解

_hashBSONElement is an internal command that is not enabled by default. _hashBSONElement must be enabled by using --setParameter enableTestCommands=1 on the mongod command line. _hashBSONElement cannot be enabled during run-time.

Example

mongod --setParameter=enableTestCommands=1

Example

Hash an ISODate string:

> db.runCommand({_hashBSONElement: ISODate("2013-02-12T22:12:57.211Z")})

Which returns the following document:

{
       "key" : ISODate("2013-02-12T22:12:57.211Z"),
       "seed" : 0,
       "out" : NumberLong("-4185544074338741873"),
       "ok" : 1
}

Hash the same ISODate string but specify a seed value:

> db.runCommand({_hashBSONElement: ISODate("2013-02-12T22:12:57.211Z"), seed:2013})

Which returns the following document:

{
       "key" : ISODate("2013-02-12T22:12:57.211Z"),
       "seed" : 2013,
       "out" : NumberLong("7845924651247493302"),
       "ok" : 1
}
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务