string-to-objectid
v1.0.5
Published
Takes strings and turns into ObjectIds
Downloads
2
Readme
String to OID
Pretty self-explanatory
Install
npm i string-to-objectid
Usage
JavaScript
const stringToOID = require('string-to-objectid')
const s = 'not a valid OID'
stringToOID(s) // Will throw a TypeError
const stringToOID = require('string-to-objectid')
const s = '5dad562161791408b2b0e639'
stringToOID(s) // ObjectId('5dad562161791408b2b0e639')
TypeScript
import stringToOID from 'string-to-objectid'
const s = 'not a valid OID'
stringToOID(s) // Will throw a TypeError
const stringToOID = require('string-to-objectid')
const s = '5dad562161791408b2b0e639'
stringToOID(s) // ObjectId('5dad562161791408b2b0e639')