Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectId

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

Hierarchy继承层级

  • ObjectId

Index索引

Constructors构造函数

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

    Parameters参数

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

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

    Returns 返回 ObjectId

Properties属性

_bsontype: "ObjectID"
cacheHexString: boolean

Accessors访问器

  • get generationTime(): number
  • set generationTime(value: number): void
  • The generation time of this ObjectId instance此ObjectId实例的生成时间

    deprecated

    Please use getTimestamp / createFromTime which returns an int32 epoch请使用返回int32历元的getTimestamp/createFromTime

    Returns 返回 number

  • The generation time of this ObjectId instance此ObjectId实例的生成时间

    deprecated

    Please use getTimestamp / createFromTime which returns an int32 epoch请使用返回int32历元的getTimestamp/createFromTime

    Parameters参数

    • value: number

    Returns 返回 void

  • get id(): Buffer
  • set id(value: Buffer): void
  • The ObjectId bytesObjectId字节

    readonly

    Returns 返回 Buffer

  • The ObjectId bytesObjectId字节

    readonly

    Parameters参数

    • value: Buffer

    Returns 返回 void

Methods方法

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

    Parameters参数

    • otherId: string | ObjectId | ObjectIdLike

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

    Returns 返回 boolean

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

    Returns 返回 Date

  • inspect(): string
  • Returns 返回 string

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

    Returns 返回 string

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

    Returns 返回 string

  • toString(format?: string): string
  • Converts the id into a 24 character hex string for printing将id转换为24个字符的十六进制字符串进行打印

    Parameters参数

    • Optional format: string

      The Buffer toString format parameter.Buffer toString格式参数。

    Returns 返回 string

  • 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

  • Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. 从第二个数字创建ObjectId,其余ObjectId为零。Used for comparisons or sorting the ObjectId.用于比较或排序ObjectId。

    Parameters参数

    • time: number

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

    Returns 返回 ObjectId

  • 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

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

    Parameters参数

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

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

    Returns 返回 boolean

Generated using TypeDoc