Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bson-objectid

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bson-objectid

Construct ObjectIDs without the mongodb driver or bson module

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
214K
decreased by-5.97%
Maintainers
2
Weekly downloads
 
Created

What is bson-objectid?

The bson-objectid npm package is a utility for generating and working with BSON ObjectIDs, which are commonly used as unique identifiers in MongoDB. This package allows you to create new ObjectIDs, convert them to strings, and parse them from strings.

What are bson-objectid's main functionalities?

Generate a new ObjectID

This feature allows you to generate a new BSON ObjectID. The generated ID is a 12-byte identifier that is unique and can be used as a primary key in MongoDB.

const ObjectId = require('bson-objectid');
const id = new ObjectId();
console.log(id.toString());

Convert ObjectID to string

This feature allows you to convert a BSON ObjectID to its string representation. This is useful for storing or transmitting the ID as a string.

const ObjectId = require('bson-objectid');
const id = new ObjectId();
const idString = id.toString();
console.log(idString);

Parse ObjectID from string

This feature allows you to parse a string representation of an ObjectID back into a BSON ObjectID. This is useful for converting IDs received as strings back into their original ObjectID format.

const ObjectId = require('bson-objectid');
const idString = '507f1f77bcf86cd799439011';
const id = ObjectId(idString);
console.log(id);

Other packages similar to bson-objectid

Keywords

FAQs

Package last updated on 11 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc