New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ee-soa-service

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-soa-service - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

95

lib/DefaultORMController.js

@@ -576,74 +576,52 @@ (function() {

, _handleHasOneSubRequest: function(entities, subRequest, callback) {
var collection = subRequest.getCollection();
var map = {};
var ids = [];
// FIXME: you could do better dude!
// ========
// use the right primary!
var primaryKey = this.specs.primaryKey;
if(primaryKey == this.specs.hasOne[collection].key) {
this.specs.primaryKeys.some(function(pkey) {
if(pkey !== this.specs.hasOne[collection].key)
{
primaryKey = pkey;
return true;
}
const collection = subRequest.collection;
const ourColumn = this.specs.hasOne[collection].key;
const otherColumn = this.specs.hasOne[collection].referencedColumn;
const mappingMap = new Map();
return false;
}.bind(this));
}
// ========
// ENDFIXME
ids = function(entities) {
var _ids = [];
entities.forEach(function(entity, entityKey) {
if(!type.number(entityKey)) return;
// get a unique set of ids
entities.forEach((entity) => {
const id = entity[ourColumn];
var id = entity[primaryKey];
if(!id) return;
if (id !== null && id !== undefined) {
if (!mappingMap.has(id)) mappingMap.set(id, new Set());
mappingMap.get(id).add(entity);
}
});
var refId = entity[this.specs.hasOne[collection].key];
if(!map[refId]) map[refId] = [];
map[refId].push(entity);
_ids.push(id);
}.bind(this));
// add filters
if (!subRequest.filters[otherColumn]) subRequest.filters[otherColumn] = [];
subRequest.filters[otherColumn].push({
operator: '='
, value: () => ({
name: 'in'
, parameters: Array.from(mappingMap.keys())
})
});
return _ids;
}.bind(this)(entities);
subRequest.getFields().push(this.specs.hasOne[collection].referencedColumn);
subRequest.filters[this.table] = {};
subRequest.filters[this.table][primaryKey] = [
{
operator : '='
, value : function() {
return {
name : 'in'
, parameters : ids
}
}.bind(this)
}
];
// Add alias support
// alias support
if(this.specs.hasOne[collection].hasAlias) subRequest.collection = this.specs.hasOne[collection].referencedModelName;
this.emit('request', subRequest, function(err, data, status, headers) {
if(err) return callback(err);
if (data && (type.object(data) || type.array(data)) && data.length) {
data.forEach(function(subEntity) {
if(map[subEntity[this.specs.hasOne[collection].referencedColumn]]) {
map[subEntity[this.specs.hasOne[collection].referencedColumn]].forEach(function(reference) {
reference[collection] = subEntity;
}.bind(this));
// get the data
this.emit('request', subRequest, (err, otherEntities, status, headers) => {
// add the laoded entities to the local ones
if (type.array(otherEntities)) {
otherEntities.forEach((otherEntity => {
const otherId = otherEntity[otherColumn];
if (mappingMap.has(otherId)) {
const set = mappingMap.get(otherId);
for (const entity of set) entity[collection] = otherEntity;
}
}.bind(this));
}));
}
callback(err, data, status, headers);
}.bind(this));
callback(err, otherEntities, status, headers);
});
}

@@ -658,2 +636,3 @@

, _handleBelongsToSubRequest: function(entities, subRequest, callback) {

@@ -660,0 +639,0 @@ var collection = subRequest.getCollection();

@@ -5,3 +5,3 @@ {

, "keywords" : ["ee", "soa", "service"]
, "version" : "1.0.2"
, "version" : "1.0.3"
, "author": {

@@ -8,0 +8,0 @@ "name" : "Tobias Kneubuehler"

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