Socket
Socket
Sign inDemoInstall

camo

Package Overview
Dependencies
124
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.2 to 0.5.3

test/issues.test.js

8

CHANGELOG.md

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

## 0.5.3 (2015-07-01)
Bugfixes:
- Fixed issue in `.loadMany()` where references in arrays were getting loaded too many times. ([#4](https://github.com/scottwrobinson/camo/issues/4)).
- Added test in issues.test.js
- Fixed issue in `.loadMany()` where muliple references to the same object were only getting loaded once. ([#5](https://github.com/scottwrobinson/camo/issues/5)).
- Added test in issues.test.js
## 0.5.2 (2015-06-30)

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

49

lib/base-document.js

@@ -323,2 +323,9 @@ "use strict";

// TODO: Is this really the most efficient
// way to do this? Maybe make a master list
// of all objects that need to be loaded (separated
// by type), load those, and then search through
// ids to see where dereferenced objects should
// go?
// ...then for each array of ids, load them all...

@@ -334,2 +341,5 @@ var loadPromises = [];

// Only want to load each reference once
keyIds = _.unique(keyIds);
// Handle array of references (like [MyObject])

@@ -347,24 +357,25 @@ var type = null;

// Assign each dereferenced object to parent
dereferences.forEach(function(deref) {
// For each model member...
_.keys(ids[key]).forEach(function(k) {
// ...if this dereference is in the array...
var cIds = [];
ids[key][k].forEach(function(i) {
cIds.push(DB().toCanonicalId(i));
_.keys(ids[key]).forEach(function(k) {
// TODO: Replace with documents.find when able
// Find the document to assign the derefs to
var doc;
documents.forEach(function(d) {
if (DB().toCanonicalId(d.id) === k) doc = d;
});
// For all ids to be dereferenced, find the
// deref and assign or push it
ids[key][k].forEach(function(id) {
// TODO: Replace with dereferences.find when able
// Find the right dereference
var deref;
dereferences.forEach(function(d) {
if (DB().toCanonicalId(d.id) === id) deref = d;
});
if (cIds.indexOf(DB().toCanonicalId(deref.id)) > -1) {
// ...find the document it belongs to...
documents.forEach(function(doc) {
// ...and make the assignment (value or array-based).
if (DB().toCanonicalId(doc.id) === k) {
if (isArray(anInstance._schema[key].type)) {
doc[key].push(deref);
} else {
doc[key] = deref;
}
}
});
if (isArray(anInstance._schema[key].type)) {
doc[key].push(deref);
} else {
doc[key] = deref;
}

@@ -371,0 +382,0 @@ });

{
"name": "camo",
"version": "0.5.2",
"version": "0.5.3",
"description": "A lightweight ES6 ODM for Mongo-like databases.",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc