Comparing version 0.0.2 to 0.0.3
# CHANGELOG.md | ||
## 0.0.3 | ||
###### _2018-04-16_ | ||
- When a query property is equal to an array, automatically convert to $in query @shawnmcknight | ||
- Change default export from library to include Connection, Errors, and Schema @shawnmcknight | ||
## 0.0.2 | ||
@@ -4,0 +9,0 @@ ###### _2018-04-09_ |
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -41,11 +41,22 @@ | ||
/** | ||
* @typedef {Object} Errors | ||
* @property {Error} ConnectionManager | ||
* @property {Error} DataValidation | ||
* @property {Error} DbServer | ||
* @property {Error} DisallowDirect | ||
* @property {Error} InvalidParameter | ||
* @property {Error} InvalidServerFeatures | ||
* @property {Error} NotImplemented | ||
* @property {Error} TransformData | ||
*/ | ||
exports.default = { | ||
ConnectionManager: _ConnectionManager2.default, | ||
DataValidation: _DataValidation2.default, | ||
DbServer: _DbServer2.default, | ||
DisallowDirect: _DisallowDirect2.default, | ||
InvalidParameter: _InvalidParameter2.default, | ||
InvalidServerFeatures: _InvalidServerFeatures2.default, | ||
NotImplemented: _NotImplemented2.default, | ||
TransformData: _TransformData2.default | ||
ConnectionManager: _ConnectionManager2.default, | ||
DataValidation: _DataValidation2.default, | ||
DbServer: _DbServer2.default, | ||
DisallowDirect: _DisallowDirect2.default, | ||
InvalidParameter: _InvalidParameter2.default, | ||
InvalidServerFeatures: _InvalidServerFeatures2.default, | ||
NotImplemented: _NotImplemented2.default, | ||
TransformData: _TransformData2.default | ||
}; |
21
index.js
@@ -6,3 +6,2 @@ 'use strict'; | ||
}); | ||
exports.Schema = exports.Errors = exports.Connection = undefined; | ||
@@ -37,2 +36,17 @@ var _Connection = require('./Connection'); | ||
/** | ||
* @member {Connection} Connection | ||
* @memberof mvom | ||
*/ | ||
Connection: _Connection2.default, | ||
/** | ||
* @member {Errors} Errors | ||
* @memberof mvom | ||
*/ | ||
Errors: _Errors2.default, | ||
/** | ||
* @member {Schema} Schema | ||
* @memberof mvom | ||
*/ | ||
Schema: _Schema2.default, | ||
/** | ||
* Create a new connection instance | ||
@@ -71,5 +85,2 @@ * @function createConnection | ||
exports.default = mvom; | ||
exports.Connection = _Connection2.default; | ||
exports.Errors = _Errors2.default; | ||
exports.Schema = _Schema2.default; | ||
exports.default = mvom; |
{ | ||
"name": "mvom", | ||
"author": "STORIS", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Multivalue Object Mapper", | ||
@@ -6,0 +6,0 @@ "main": "./index.js", |
@@ -320,5 +320,3 @@ 'use strict'; | ||
const andConditions = Object.keys(criteria).map(queryProperty => { | ||
const queryValue = criteria[queryProperty]; | ||
const andConditions = Object.entries(criteria).map(([queryProperty, queryValue]) => { | ||
if (queryProperty === '$or') { | ||
@@ -339,4 +337,9 @@ if (!Array.isArray(queryValue) || queryValue.length === 0) { | ||
if (Array.isArray(queryValue)) { | ||
// assume $in operator if queryValue is an array | ||
return Query.formatConditionList(dictionaryId, '=', queryValue, 'or'); | ||
} | ||
if (!(0, _isPlainObject2.default)(queryValue)) { | ||
// assume equality if not an object | ||
// assume equality if queryValue is not an object | ||
return Query.formatCondition(dictionaryId, '=', queryValue); | ||
@@ -346,4 +349,3 @@ } | ||
// if query value is an object then it should contain one or more pairs of operator and value | ||
const operatorConditions = Object.keys(queryValue).map(operator => { | ||
const mvValue = queryValue[operator]; | ||
const operatorConditions = Object.entries(queryValue).map(([operator, mvValue]) => { | ||
switch (operator) { | ||
@@ -390,4 +392,3 @@ case '$eq': | ||
return Object.keys(criteria).map(sortProperty => { | ||
const sortOrder = criteria[sortProperty]; | ||
return Object.entries(criteria).map(([sortProperty, sortOrder]) => { | ||
const dictionaryId = this._getDictionaryId(sortProperty); | ||
@@ -394,0 +395,0 @@ |
173385
3218