js-data-sql
Advanced tools
Comparing version 0.11.7 to 0.11.8
@@ -235,25 +235,31 @@ module.exports = | ||
if (instance) { | ||
task = _this.find(resourceConfig.getResource(relationName), DSUtils.get(instance, def.localKey), __options).then(function (relatedItem) { | ||
instance[def.localField] = relatedItem; | ||
return relatedItem; | ||
var id = DSUtils.get(instance, def.localKey); | ||
if (id) { | ||
task = _this.find(resourceConfig.getResource(relationName), DSUtils.get(instance, def.localKey), __options).then(function (relatedItem) { | ||
instance[def.localField] = relatedItem; | ||
return relatedItem; | ||
}); | ||
} | ||
} else { | ||
var ids = DSUtils.filter(items.map(function (item) { | ||
return DSUtils.get(item, def.localKey); | ||
}), function (x) { | ||
return x; | ||
}); | ||
} else { | ||
task = _this.findAll(resourceConfig.getResource(relationName), { | ||
where: _defineProperty({}, relationDef.idAttribute, { | ||
'in': DSUtils.filter(items.map(function (item) { | ||
return DSUtils.get(item, def.localKey); | ||
}), function (x) { | ||
return x; | ||
if (ids.length) { | ||
task = _this.findAll(resourceConfig.getResource(relationName), { | ||
where: _defineProperty({}, relationDef.idAttribute, { | ||
'in': ids | ||
}) | ||
}) | ||
}, __options).then(function (relatedItems) { | ||
DSUtils.forEach(items, function (item) { | ||
DSUtils.forEach(relatedItems, function (relatedItem) { | ||
if (relatedItem[relationDef.idAttribute] === item[def.localKey]) { | ||
item[def.localField] = relatedItem; | ||
} | ||
}, __options).then(function (relatedItems) { | ||
DSUtils.forEach(items, function (item) { | ||
DSUtils.forEach(relatedItems, function (relatedItem) { | ||
if (relatedItem[relationDef.idAttribute] === item[def.localKey]) { | ||
item[def.localField] = relatedItem; | ||
} | ||
}); | ||
}); | ||
return relatedItems; | ||
}); | ||
return relatedItems; | ||
}); | ||
} | ||
} | ||
@@ -507,2 +513,4 @@ } | ||
query = query.where(field, 'like', v); | ||
} else if (op === '|like') { | ||
query = query.orWhere(field, 'like', v); | ||
} else if (op === '|==' || op === '|===') { | ||
@@ -509,0 +517,0 @@ if (v === null) { |
{ | ||
"name": "js-data-sql", | ||
"description": "Postgres/MySQL/MariaDB/SQLite3 adapter for js-data.", | ||
"version": "0.11.7", | ||
"version": "0.11.8", | ||
"homepage": "http://www.js-data.io/docs/dssqladapter", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -76,3 +76,7 @@ <img src="https://raw.githubusercontent.com/js-data/js-data/master/js-data.png" alt="js-data logo" title="js-data" align="right" width="64" height="64" /> | ||
1. Run `npm test` (build and test) | ||
- You need io.js or Node 4.x that includes generator support without a flag | ||
- You need Node 4.x that includes generator support without a flag | ||
- The tests expect a database to be running follows, but can be overridden by passing the applicable environment variable as indicated (ex. `DB_HOST=192.168.99.100 npm test`). | ||
- `DB_HOST`: `localhost` | ||
- `DB_NAME`: `circle_test` | ||
- `DB_USER`: `ubuntu` | ||
1. Your code will be linted and checked for formatting, the tests will be run | ||
@@ -79,0 +83,0 @@ 1. The `dist/` folder & files will be generated, do NOT commit `dist/*`! They |
38626
9
563
137