sails-disk
Advanced tools
Comparing version 0.10.0-rc3 to 0.10.0-rc4
@@ -92,2 +92,4 @@ /*--------------------------------------------------------------- | ||
adapter.createEach = adapter.create; | ||
/** | ||
@@ -94,0 +96,0 @@ * Grab the connection object for a connection name |
@@ -330,15 +330,25 @@ /** | ||
// Check Uniqueness Constraints | ||
var errors = this.uniqueConstraint(collectionName, values); | ||
if(errors && errors.length > 0) return cb(errors); | ||
var self = this; | ||
// Auto-Increment any values | ||
values = this.autoIncrement(collectionName, values); | ||
values = this.serializeValues(collectionName, values); | ||
function addRecord(record) { | ||
if (!this.data[collectionName]) return cb(Errors.CollectionNotRegistered); | ||
this.data[collectionName].push(values); | ||
// Check Uniqueness Constraints | ||
var errors = self.uniqueConstraint(collectionName, record); | ||
if(errors && errors.length > 0) return cb(errors); | ||
// Auto-Increment any values | ||
record = self.autoIncrement(collectionName, record); | ||
record = self.serializeValues(collectionName, record); | ||
if (!self.data[collectionName]) return cb(Errors.CollectionNotRegistered); | ||
self.data[collectionName].push(record); | ||
} | ||
var originalValues = _.clone(values); | ||
if(!Array.isArray(values)) values = [values]; | ||
values.forEach(addRecord); | ||
this.write(collectionName, function() { | ||
cb(null, values); | ||
cb(null, Array.isArray(originalValues) ? values : values[0]); | ||
}); | ||
@@ -387,5 +397,8 @@ }; | ||
var result = self.data[collectionName][resultSet.indices[0]]; | ||
var records = _.reject(self.data[collectionName], result); | ||
var errors = []; | ||
_.each(uniqueAttrs, function(uniqueAttr) { | ||
if (result[uniqueAttr] != values[uniqueAttr]) { | ||
// look for matching values in all records. note: this is case sensitive. | ||
if (!!~_.pluck(records, uniqueAttr).indexOf(values[uniqueAttr])) { | ||
errors.push(new Error('Uniqueness check failed on attribute: ' + uniqueAttr + ' with value: ' + values[uniqueAttr])); | ||
@@ -392,0 +405,0 @@ } |
{ | ||
"name": "sails-disk", | ||
"version": "0.10.0-rc3", | ||
"version": "0.10.0-rc4", | ||
"description": "Persistent local-disk adapter for Sails.js / Waterline", | ||
@@ -32,3 +32,3 @@ "main": "lib/adapter.js", | ||
"lodash": "~2.4.1", | ||
"waterline-criteria": "~0.10.2", | ||
"waterline-criteria": "~0.10.3", | ||
"waterline-errors": "~0.10.0", | ||
@@ -47,3 +47,2 @@ "fs-extra": "~0.8.1", | ||
"semantic", | ||
"migratable", | ||
"queryable", | ||
@@ -50,0 +49,0 @@ "associations" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24406
7
677
Updatedwaterline-criteria@~0.10.3