Class ObjectId

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

Hierarchy

Constructors

  • Create an ObjectId type创建ObjectId类型

    Parameters

    • Optional inputId: string | number | Uint8Array | ObjectId | ObjectIdLike

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

    Returns ObjectId

Properties

cacheHexString: boolean

Accessors

  • get _bsontype(): "ObjectId"
  • Returns "ObjectId"

  • get id(): Uint8Array
  • The ObjectId bytes

    Returns Uint8Array

Methods

  • Compares the equality of this ObjectId with otherID.比较此ObjectId与otherID的相等性。

    Parameters

    • otherId: undefined | null | string | ObjectId | ObjectIdLike

      ObjectId instance to compare against.要与之进行比较的ObjectId实例。

    Returns boolean

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

    Returns Date

  • Returns string

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

    Returns string

  • Converts to its JSON the 24 character hex string representation.将24个字符的十六进制字符串表示形式转换为JSON。

    Returns string

  • Converts the id into a 24 character hex string for printing, unless encoding is provided.将id转换为24个字符的十六进制字符串以进行打印,除非提供了编码。

    Parameters

    • Optional encoding: "base64" | "hex"

      hex or base64

    Returns string

  • Creates an ObjectId instance from a base64 string从base64字符串创建ObjectId实例

    Parameters

    • base64: string

    Returns 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

  • 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

  • Generate a 12 byte id buffer used in ObjectId's生成ObjectId中使用的12字节id缓冲区

    Parameters

    • Optional time: number

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

    Returns Uint8Array

  • Checks if a value can be used to create a valid bson ObjectId检查值是否可用于创建有效的bson ObjectId

    Parameters

    Returns boolean

Generated using TypeDoc