2.0.1 • Published 3 years ago

mongoose-guid v2.0.1

Weekly downloads
156
License
MIT
Repository
github
Last release
3 years ago

mongoose-guid

GUID type for mongoose

Mongoose GUID Data type

Why

In a .NET project? Yeah .NET GUID is a UUID V3 and node do not have support to this!

How to use

const mongoose = require('mongoose');
const GUID = require('mongoose-guid')(mongoose);
const Schema = mongoose.Schema;

const ProductSchema = Schema({
  _id: { type: GUID.type, default: GUID.value },
  name: String
}, { id: false });

ProductSchema.set('toObject', {getters: true});
ProductSchema.set('toJSON', {getters: true});

const Product = mongoose.model('Product', ProductSchema);

Arrays

To create arrays of GUIDs use the property Array

const ProductSchema = Schema(
  {
    _id: { type: GUID.type, default: GUID.value },
    ids: GUID.Array,
  },
  { id: false }
);
2.0.1

3 years ago

2.0.0

3 years ago

1.0.31

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago