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

js-data

Package Overview
Dependencies
Maintainers
1
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-data - npm Package Compare versions

Comparing version 3.0.0-rc.3 to 3.0.0-rc.4

README.md

8

CHANGELOG.md

@@ -0,1 +1,9 @@

##### 3.0.0-rc.4 - 03 August 2016
###### Bug fixes
- #376 - Fix unlinking of records
- #379 fixes #380 - fix(hasOne): do not create links for undefined or null keys by @nickescallon
- #382 fixes #381 - check that inverseDef exists before attempting to setup Inverse for belongsTo by @pik
- #384 - DataStore does not correctly call super
##### 3.0.0-rc.3 - 25 July 2016

@@ -2,0 +10,0 @@

10

package.json
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "3.0.0-rc.3",
"version": "3.0.0-rc.4",
"homepage": "http://www.js-data.io",

@@ -58,3 +58,3 @@ "repository": {

"bundle:es5": "rollup src/index.js -c -o dist/js-data.js -m dist/js-data.js.map -f umd",
"bundle:next": "rollup src/index.js -c -o dist/js-data.es2015.js -m dist/js-data.es2015.js.map -f es6",
"bundle:next": "rollup src/index.js -c -o dist/js-data.es2015.js -m dist/js-data.es2015.js.map -f es",
"bundle": "npm run bundle:es5 && npm run bundle:next && repo-tools write-version dist/js-data.js dist/js-data.es2015.js",

@@ -73,6 +73,6 @@ "min": "uglifyjs dist/js-data.js -o dist/js-data.min.js --source-map dist/js-data.min.map --source-map-url js-data.min.map -v -m -c --keep-fnames --screw-ie8",

"babel-plugin-syntax-async-functions": "6.8.0",
"babel-plugin-transform-es2015-modules-umd": "6.8.0",
"babel-plugin-transform-es2015-modules-umd": "6.12.0",
"babel-plugin-transform-regenerator": "6.11.4",
"js-data-repo-tools": "0.5.5",
"karma": "1.1.1",
"karma": "1.1.2",
"karma-babel-preprocessor": "6.0.1",

@@ -85,5 +85,5 @@ "karma-chai": "0.1.0",

"karma-sinon": "1.0.5",
"phantomjs-prebuilt": "2.1.7",
"phantomjs-prebuilt": "2.1.10",
"uglify-js": "2.7.0"
}
}

@@ -103,4 +103,2 @@ import utils from './utils'

if (mapper.relationList.length && record) {
// Check the currently visited record for relations that need to be
// inserted into their respective collections.
mapper.relationList.forEach(function (def) {

@@ -120,4 +118,2 @@ def.removeLinkedRecords(mapper, [record])

if (mapper.relationList.length && records.length) {
// Check the currently visited record for relations that need to be
// inserted into their respective collections.
mapper.relationList.forEach(function (def) {

@@ -124,0 +120,0 @@ def.removeLinkedRecords(mapper, records)

@@ -1,4 +0,9 @@

import utils from './utils'
import utils, { safeSetLink } from './utils'
import Component from './Component'
import Settable from './Settable'
import {
belongsToType,
hasManyType,
hasOneType
} from './decorators'

@@ -389,2 +394,32 @@ const DOMAIN = 'Record'

removeInverseRelation(currentParent, id, inverseDef, idAttribute) {
if (inverseDef.type === hasOneType) {
safeSetLink(currentParent, inverseDef.localField, undefined)
} else if (inverseDef.type === hasManyType) {
// e.g. remove comment from otherPost.comments
const children = utils.get(currentParent, inverseDef.localField)
if (id === undefined) {
utils.remove(children, (child) => child === this)
} else {
utils.remove(children, (child) => child === this || id === utils.get(child, idAttribute))
}
}
},
setupInverseRelation(record, id, inverseDef, idAttribute) {
// Update (set) inverse relation
if (inverseDef.type === hasOneType) {
// e.g. someUser.profile = profile
safeSetLink(record, inverseDef.localField, this)
} else if (inverseDef.type === hasManyType) {
// e.g. add comment to somePost.comments
const children = utils.get(record, inverseDef.localField)
if (id === undefined) {
utils.noDupeAdd(children, this, (child) => child === this)
} else {
utils.noDupeAdd(children, this, (child) => child === this || id === utils.get(child, idAttribute))
}
}
},
/**

@@ -391,0 +426,0 @@ * Lazy load relations of this record, to be attached to the record once their

@@ -158,4 +158,2 @@ import utils from './utils'

records.forEach((record) => {
const relatedData = utils.get(record, localField)
this.unlinkInverseRecords(relatedData)
utils.set(record, localField, undefined)

@@ -165,9 +163,2 @@ })

unlinkInverseRecords (record) {
if (!record) {
return
}
utils.set(record, this.getInverse(this.mapper).localField, undefined)
},
linkRecord (record, relatedRecord) {

@@ -198,2 +189,5 @@ const relatedId = utils.get(relatedRecord, this.mapper.idAttribute)

findExistingLinksByForeignKey (id) {
if (id === undefined || id === null) {
return
}
return this.relatedCollection.filter({

@@ -200,0 +194,0 @@ [this.foreignKey]: id

@@ -20,12 +20,2 @@ import utils from '../utils'

unlinkInverseRecords (records) {
if (!records) {
return
}
const localField = this.getInverse(this.mapper).localField
records.forEach(function (record) {
utils.set(record, localField, undefined)
})
},
linkRecord (record, relatedRecords) {

@@ -32,0 +22,0 @@ const relatedCollection = this.relatedCollection

@@ -9,3 +9,3 @@ import utils from '../utils'

if (records.length) {
if (records && records.length) {
return records[0]

@@ -12,0 +12,0 @@ }

@@ -1579,5 +1579,22 @@ /**

object[last] = undefined
},
}
export const safeSetProp = function (record, field, value) {
if (record && record._set) {
record._set(`props.${field}`, value)
} else {
utils.set(record, field, value)
}
}
export const safeSetLink = function (record, field, value) {
if (record && record._set) {
record._set(`links.${field}`, value)
} else {
utils.set(record, field, value)
}
}
export default utils

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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