Socket
Socket
Sign inDemoInstall

waterline-schema

Package Overview
Dependencies
3
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-21 to 1.0.0-22

20

lib/waterline-schema/joinTables.js

@@ -62,12 +62,16 @@ // ██████╗ ██╗ ██╗██╗██╗ ██████╗

// exists on the other model.
if (_.has(attributeVal, 'via') && !relatedModel.schema[attributeVal.via]) {
throw flaverr({ name: 'userError' }, new Error('The collection association defined for attribute `' + attributeName + '` on the `' + collection.identity + '` model points to an attribute using `via` on the `' + relatedModel.identity + '` model that doesn\'t exist.'));
if (_.has(attributeVal, 'via')) {
if (!relatedModel.schema[attributeVal.via]) {
throw flaverr({ name: 'userError' }, new Error('The collection association defined for attribute `' + attributeName + '` on the `' + collection.identity + '` model points to an attribute using `via` on the `' + relatedModel.identity + '` model that doesn\'t exist.'));
}
// Check if it's a foreign key. If so this is a one-to-many relationship and no join table is needed.
if (_.has(relatedModel.schema[attributeVal.via], 'foreignKey')) {
return;
}
// Otherwise check that it points back to this model.
if (!relatedModel.schema[attributeVal.via].collection || relatedModel.schema[attributeVal.via].collection !== collectionName) {
throw flaverr({ name: 'userError' }, new Error('The collection association defined for attribute `' + attributeName + '` on the `' + collection.identity + '` model points to an attribute using `via` on the `' + relatedModel.identity + '` model that doesn\'t point back to `' + relatedModel.identity + '`.'));
}
}
// If a `via` is used, check if it's a foreign key. If so this is a one-to-many
// relationship and no join table is needed.
if (_.has(attributeVal, 'via') && _.has(relatedModel.schema[attributeVal.via], 'foreignKey')) {
return;
}
// If no via is specified, a name needs to be created for the other column

@@ -74,0 +78,0 @@ // in the join table. Use the attribute key and the associated collection name

2

package.json
{
"name": "waterline-schema",
"description": "The core schema builder used in the Waterline ORM.",
"version": "1.0.0-21",
"version": "1.0.0-22",
"dependencies": {

@@ -6,0 +6,0 @@ "@sailshq/lodash": "^3.10.2",

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