New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uuid-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uuid-mongodb - npm Package Compare versions

Comparing version 1.0.2 to 1.1.1

3

lib/index.js

@@ -29,2 +29,3 @@ const { Binary } = require('mongodb');

return stringify(uuid.read(0, uuid.length()));
} else {
throw Err.UnexpectedUUIDType;

@@ -35,3 +36,3 @@ }

function generateUUID(uuid = undefined, v = 1) {
function generateUUID(uuid, v = 1) {
if (v <= 0 || v > 4 || v === 2 || v === 3) throw Err.UnsupportedUUIDVersion;

@@ -38,0 +39,0 @@

{
"name": "uuid-mongodb",
"version": "1.0.2",
"version": "1.1.1",
"description": "",

@@ -31,4 +31,4 @@ "main": "lib/index.js",

"mocha": "^5.2.0",
"mongodb": "^3.1.1"
"mongodb": "^3.1.10"
}
}
# uuid-mongodb
![](https://img.shields.io/badge/status-stable-green.svg) ![](https://img.shields.io/badge/tests-passing-green.svg) ![](https://img.shields.io/badge/license-MIT-blue.svg)
Generates and parses [BSON UUIDs](https://docs.mongodb.com/manual/reference/method/UUID/) for use with MongoDB. BSON UUIDs provide better performance than their string counterparts.

@@ -20,2 +22,4 @@

```javascript
const MUUID = require('uuid-mongodb');
# Create a v1 binary UUID

@@ -33,3 +37,3 @@ const mUUID1 = MUUID.v1();

# Create a binary UUID from a MongoDb Binary
# Create a binary UUID from a MongoDb Binary
# This is useful to get MUUIDs helpful toString() method

@@ -39,14 +43,23 @@ const mUUID3 = MUUID.from(/** MongoDb Binary of SUBTYPE_UUID */)

## Example
## Examples
### Query
#### Query using binary UUIDs
```javascript
const uuid = MUUID.from('393967e0-8de1-11e8-9eb6-529269fb1459');
const uuid = MUUID.from('393967e0-8de1-11e8-9eb6-529269fb1459');
return collection.then(c =>
c.findOne({
_id: uuid,
})
);
```
##### Work with binary UUIDs returned in query results
```javascript
return collection
.then(c =>
c.findOne({
_id: uuid,
})
)
.then(c => c.findOne({ _id: uuid }))
.then(doc => {
const uuid = MUUID.from(doc._id).toString()
// do stuff
})
```

@@ -53,0 +66,0 @@

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