objectid
mongodb objectid utilities
Last updated 13 years ago by jden .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install objectid 
SYNC missed versions from official npm registry.

objectid

mongodb objectid utilities

about

1.x is probably the version you want to use in a browser. 3.x focuses on compatibility with the npm mongodb driver.

installation

$ npm install objectid

usage

var objectid = require('objectid')

var id = objectid()

objectid.isValid(id)
// => true

objectid.isValid('4frsdef43wzx')
// => false

objectid.isValid returns true for mongodb native driver ObjectID objects, or any other representations with a .toString method which returns the hex string encoding of a valid objectid.

Calling objectid with an existing objectid - whether a string, an object created by this module, an objectid created by another driver (such as the result of a query) - will cast the value to an instanceof this module. It will throw if the argument is not a valid ObjectId.

Static Methods

ObjectId.equals(oidA, oidB) => Boolean

Curried to support creating equality predicates.

ObjectId.tryParse(oid, out, as) => Boolean

ObjectId.isValid(oid) => Boolean

Instance Methods

ObjectId#equals(oidB) => Boolean

ObjectId#toString() => String

ObjectId#toJSON() => String

running the tests

From package root:

$ npm install
$ npm test

contributors

jden jason@denizac.org @leJDen

license

MIT. (c) 2013 Agile Diagnosis hello@agilediagnosis.com See LICENSE.md

Current Tags

  • 3.2.1                                ...           latest (11 years ago)

11 Versions

  • 3.2.1                                ...           11 years ago
  • 3.2.0                                ...           11 years ago
  • 3.1.0                                ...           13 years ago
  • 3.0.1                                ...           13 years ago
  • 3.0.0                                ...           13 years ago
  • 2.3.0                                ...           13 years ago
  • 2.2.0                                ...           13 years ago
  • 2.1.0                                ...           13 years ago
  • 2.0.0                                ...           13 years ago
  • 1.1.0                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |