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

adonis-lucid-mongodb

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis-lucid-mongodb - npm Package Compare versions

Comparing version 0.11.4 to 0.11.5

2

package.json

@@ -8,3 +8,3 @@ {

},
"version": "0.11.4",
"version": "0.11.5",
"scripts": {

@@ -11,0 +11,0 @@ "lint": "standard",

@@ -16,3 +16,2 @@ 'use strict'

const ObjectID = require('mongodb').ObjectID
const mquery = require('mquery')
const methods = exports = module.exports = {}

@@ -19,0 +18,0 @@

@@ -20,7 +20,18 @@ 'use strict'

constructor (parent, related, determine, primaryKey, foreignKey) {
/**
* Creates an instance of MorphMany.
*
* @param {String} parent
* @param {String} related
* @param {String} determiner
* @param {String} foreignKey
* @param {String} primaryKey
*
* @memberOf MorphMany
*/
constructor (parent, related, determiner, foreignKey, primaryKey) {
super(parent, related)
this.fromKey = primaryKey || this.parent.constructor.primaryKey
this.toKey = foreignKey || this.parent.constructor.foreignKey
this.determine = determine || 'parent'
this.toKey = foreignKey || 'parentId'
this.determiner = determiner || 'parentType'
}

@@ -44,7 +55,7 @@

const results = yield this.relatedQuery
.where(`${this.determine}_type`, this.parent.constructor.name)
.whereIn(`${this.determine}_id`, values).fetch()
.where(this.determiner, this.parent.constructor.name)
.whereIn(this.toKey, values).fetch()
return results.groupBy((item) => {
return item[`${this.determine}_id`]
return item[this.toKey]
}).mapValues(function (value) {

@@ -73,4 +84,4 @@ return helpers.toCollection(value)

const results = yield this.relatedQuery
.where(`${this.determine}_type`, this.parent.constructor.name)
.where(`${this.determine}_id`, value).fetch()
.where(this.determiner, this.parent.constructor.name)
.whereIn(this.toKey, value).fetch()
const response = {}

@@ -99,4 +110,4 @@ response[value] = results

}
relatedInstance.set(`${this.determine}_type`, this.parent.constructor.name)
relatedInstance.set(`${this.determine}_id`, this.parent[this.fromKey])
relatedInstance.set(this.determiner, this.parent.constructor.name)
relatedInstance.set(this.toKey, this.parent[this.fromKey])
return yield relatedInstance.save()

@@ -103,0 +114,0 @@ }

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