Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectId

A class representation of the BSON ObjectId type.BSON ObjectId类型的类表示形式。

Hierarchy层级

  • ObjectId

Index索引

Constructors构造函数

constructor

  • new ObjectId(id?: string | number | Buffer | ObjectId | ObjectIdLike): ObjectId
  • Create an ObjectId type创建ObjectId类型

    Parameters参数

    • Optional id: string | number | Buffer | ObjectId | ObjectIdLike

      Can be a 24 character hex string, 12 byte binary Buffer, or a number.可以是24个字符的十六进制字符串、12字节二进制缓冲区或数字。

    Returns返回ObjectId

Properties属性

_bsontype

_bsontype: "ObjectId"

generationTime

generationTime: number

id

id: Buffer

Static cacheHexString

cacheHexString: boolean

Methods方法

equals

  • equals(otherId: string | ObjectId | ObjectIdLike): boolean
  • Compares the equality of this ObjectId with otherID.比较此ObjectId与otherID的相等性。

    Parameters参数

    • otherId: string | ObjectId | ObjectIdLike

      ObjectId instance to compare against.要比较的ObjectId实例。

    Returns返回boolean

getTimestamp

  • getTimestamp(): Date
  • Returns the generation date (accurate up to the second) that this ID was generated.返回生成此ID的生成日期(精确到秒)。

    Returns返回Date

inspect

  • inspect(): string
  • Returns返回string

toHexString

  • toHexString(): string
  • Returns the ObjectId id as a 24 character hex string representation以24个字符的十六进制字符串表示形式返回ObjectId

    Returns返回string

Static createFromHexString

  • createFromHexString(hexString: string): ObjectId
  • Creates an ObjectId from a hex string representation of an ObjectId.从ObjectId的十六进制字符串表示形式创建ObjectId。

    Parameters参数

    • hexString: string

      create a ObjectId from a passed in 24 character hexstring.从传入的24个字符的十六进制字符串创建ObjectId。

    Returns返回ObjectId

Static createFromTime

  • createFromTime(time: number): ObjectId
  • Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.从第二个数字创建ObjectId,并将ObjectId的其余部分置零。用于对ObjectId进行比较或排序。

    Parameters参数

    • time: number

      an integer number representing a number of seconds.表示秒数的整数。

    Returns返回ObjectId

Static generate

  • generate(time?: number): Buffer
  • Generate a 12 byte id buffer used in ObjectId's生成ObjectId中使用的12字节id缓冲区

    Parameters参数

    • Optional time: number

      pass in a second based timestamp.传入第二个基于时间戳的时间戳。

    Returns返回Buffer

Static isValid

  • isValid(id: string | number | Uint8Array | ObjectId | ObjectIdLike): boolean
  • Checks if a value is a valid bson ObjectId检查值是否为有效的bson对象ID

    Parameters参数

    • id: string | number | Uint8Array | ObjectId | ObjectIdLike

      ObjectId instance to validate.要验证的ObjectId实例。

    Returns返回boolean

Generated using TypeDoc使用TypeDoc生成