Skip to content

Commit da34a47

Browse files
committed
Stable Version 3.0.0-alpha.2
1 parent 68856d7 commit da34a47

File tree

7 files changed

+24
-119
lines changed

7 files changed

+24
-119
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
##### 3.0.0-alpha.2 - 13 February 2016
2+
3+
- Now making use of JSData.utils.forEachRelation
4+
5+
##### 3.0.0-alpha.1 - 13 February 2016
6+
7+
- Added support for `raw` option
8+
- Added lifecycle hooks
9+
110
##### 2.3.2 - 12 December 2015
211

312
###### Backwards compatible bug fixes

dist/js-data-localstorage.js

Lines changed: 6 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js-data-localstorage.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js-data-localstorage.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js-data-localstorage.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-localstorage",
33
"description": "localStorage adapter for js-data.",
4-
"version": "3.0.0-alpha.1",
4+
"version": "3.0.0-alpha.2",
55
"homepage": "https://github.com/js-data/js-data-localstorage",
66
"repository": {
77
"type": "git",
@@ -38,7 +38,7 @@
3838
"ci": "npm test && cat ./coverage/PhantomJS*/lcov.info | coveralls || true && cat ./coverage/PhantomJS*/lcov.info | codacy-coverage || true"
3939
},
4040
"dependencies": {
41-
"js-data": "^3.0.0-alpha.13"
41+
"js-data": "^3.0.0-alpha.14"
4242
},
4343
"devDependencies": {
4444
"babel-core": "6.5.2",

src/index.js

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const {
99

1010
const {
1111
addHiddenPropsToTarget,
12-
copy,
1312
deepMixIn,
1413
extend,
1514
fillIn,
15+
forEachRelation,
1616
forOwn,
1717
fromJson,
1818
get,
@@ -561,35 +561,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, {
561561
}
562562
record = fromJson(record)
563563
const tasks = []
564-
const relationList = mapper.relationList || []
565564

566-
relationList.forEach(function (def) {
567-
const relationName = def.relation
565+
forEachRelation(mapper, opts, function (def, __opts) {
568566
const relatedMapper = def.getRelation()
569-
let containedName = null
570-
if (opts.with.indexOf(relationName) !== -1) {
571-
containedName = relationName
572-
} else if (opts.with.indexOf(def.localField) !== -1) {
573-
containedName = def.localField
574-
}
575-
if (!containedName) {
576-
return
577-
}
578-
let __opts = copy(opts)
579-
__opts.with = opts.with.slice()
580-
fillIn(__opts, relatedMapper)
581-
const index = __opts.with.indexOf(containedName)
582-
if (index >= 0) {
583-
__opts.with.splice(index, 1)
584-
}
585-
__opts.with.forEach(function (relation, i) {
586-
if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {
587-
__opts.with[i] = relation.substr(containedName.length + 1)
588-
} else {
589-
__opts.with[i] = ''
590-
}
591-
})
592-
593567
let task
594568

595569
if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {
@@ -690,35 +664,9 @@ addHiddenPropsToTarget(LocalStorageAdapter.prototype, {
690664
})
691665
records = _query.filter(query).run()
692666
const tasks = []
693-
const relationList = mapper.relationList || []
694667

695-
relationList.forEach(function (def) {
696-
const relationName = def.relation
668+
forEachRelation(mapper, opts, function (def, __opts) {
697669
const relatedMapper = def.getRelation()
698-
let containedName = null
699-
if (opts.with.indexOf(relationName) !== -1) {
700-
containedName = relationName
701-
} else if (opts.with.indexOf(def.localField) !== -1) {
702-
containedName = def.localField
703-
}
704-
if (!containedName) {
705-
return
706-
}
707-
let __opts = copy(opts)
708-
__opts.with = opts.with.slice()
709-
fillIn(__opts, relatedMapper)
710-
const index = __opts.with.indexOf(containedName)
711-
if (index >= 0) {
712-
__opts.with.splice(index, 1)
713-
}
714-
__opts.with.forEach(function (relation, i) {
715-
if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') {
716-
__opts.with[i] = relation.substr(containedName.length + 1)
717-
} else {
718-
__opts.with[i] = ''
719-
}
720-
})
721-
722670
let task
723671

724672
if ((def.type === 'hasOne' || def.type === 'hasMany') && def.foreignKey) {

0 commit comments

Comments
 (0)