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

camouflage

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camouflage - npm Package Compare versions

Comparing version 0.8.10 to 0.8.11

19

lib/clients/mongoclient.js

@@ -233,2 +233,21 @@ "use strict";

createIndex(collection, columnName, indexType, options){
options = options || {};
var that = this;
return new Promise(function(resolve, reject){
var db = that._mongo.collection(collection);
var indexDef = columnName;
if(typeof indexType === 'string'){
indexDef = { [columnName]: indexType };
}
db.createIndex(indexDef, { unique: options.unique, sparse: options.sparse }, function(err){
if(err){
reject(err);
} else {
resolve(true);
}
});
});
}
static connect(url, options) {

@@ -235,0 +254,0 @@ if (typeof(options) === 'undefined') {

@@ -298,2 +298,17 @@ "use strict";

createIndex(collection, columnName, indexType, options){
options = options || {};
var that = this;
return new Promise(function(resolve, reject){
var db = getCollection(collection, that._collections, that._path);
db.ensureIndex({ fieldName: columnName, unique: options.unique, sparse: options.sparse }, function(err){
if(err){
reject(err);
} else {
resolve(true);
}
})
});
}
static connect(url, options) {

@@ -300,0 +315,0 @@ // Could be directory path or 'memory'

@@ -28,2 +28,19 @@ "use strict";

static _initializeIndexes(){
if(this.indexesInitialized){
return;
}
this.indexesInitialized = true;
var instance = this._instantiate();
var schema = instance._schema;
for (var key in schema){
if(schema.hasOwnProperty(key)){
let indexType = schema[key].index;
if(indexType){
DB().createIndex(instance._meta.collection, key, indexType);
}
}
}
}
documentClass() {

@@ -30,0 +47,0 @@ return 'document';

2

package.json
{
"name": "camouflage",
"version": "0.8.10",
"version": "0.8.11",
"description": "A class-based ES6 ODM for Mongo-like databases.",

@@ -5,0 +5,0 @@ "author": {

@@ -150,3 +150,4 @@ # Camouflage

max: 25,
choices: [2, 3, 5, 7, 11, 13, 17, 19, 23]
choices: [2, 3, 5, 7, 11, 13, 17, 19, 23],
index: true
}

@@ -164,2 +165,3 @@ ```

- `validate`: A 1-argument function that returns `false` if the value is invalid *(optional)*
- `index`: Create an index on the given field if `true` or a string; a string can be supplied to define the index type, like `'2d'` *(optional)*

@@ -166,0 +168,0 @@ To reference another document, just use its class name as the type.

Sorry, the diff of this file is not supported yet

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