Socket
Socket
Sign inDemoInstall

waterline-schema

Package Overview
Dependencies
1
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.5 to 0.1.6

4

lib/waterline-schema.js

@@ -23,3 +23,3 @@

module.exports = function(collections, connections) {
module.exports = function(collections, connections, defaults) {

@@ -29,3 +29,3 @@ this.schema = {};

// Transform Collections into a basic schema
this.schema = new Attributes(collections, connections);
this.schema = new Attributes(collections, connections, defaults);

@@ -32,0 +32,0 @@ // Build Out Foreign Keys

@@ -28,3 +28,3 @@

function Attributes(collections, connections) {
function Attributes(collections, connections, defaults) {
var self = this;

@@ -38,3 +38,3 @@

for(var key in collections) {
var collection = this.normalize(collections[key].prototype, connections),
var collection = this.normalize(collections[key].prototype, connections, defaults),
conns = _.cloneDeep(collection.connection),

@@ -67,5 +67,5 @@ attributes = _.cloneDeep(collection.attributes);

Attributes.prototype.normalize = function(collection, connections) {
Attributes.prototype.normalize = function(collection, connections, defaults) {
this.normalizeIdentity(collection);
this.setDefaults(collection);
this.setDefaults(collection, defaults);
this.autoAttributes(collection, connections);

@@ -86,4 +86,7 @@

Attributes.prototype.setDefaults = function(collection) {
Attributes.prototype.setDefaults = function(collection, defaults) {
// Ensure defaults is always set to something
defaults = defaults || {};
if(!hasOwnProperty(collection, 'connection')) {

@@ -97,6 +100,22 @@ collection.connection = '';

var defaultSettings = {
autoPK: true,
autoCreatedAt: true,
autoUpdatedAt: true
};
// Override default settings with user defined defaults
if(hasOwnProperty(defaults, 'autoPK')) defaultSettings.autoPK = defaults.autoPK;
if(hasOwnProperty(defaults, 'autoCreatedAt')) defaultSettings.autoCreatedAt = defaults.autoCreatedAt;
if(hasOwnProperty(defaults, 'autoUpdatedAt')) defaultSettings.autoUpdatedAt = defaults.autoUpdatedAt;
// Override defaults with collection defined values
if(hasOwnProperty(collection, 'autoPK')) defaultSettings.autoPK = collection.autoPK;
if(hasOwnProperty(collection, 'autoCreatedAt')) defaultSettings.autoCreatedAt = collection.autoCreatedAt;
if(hasOwnProperty(collection, 'autoUpdatedAt')) defaultSettings.autoUpdatedAt = collection.autoUpdatedAt;
var flags = {
autoPK: hasOwnProperty(collection, 'autoPK') ? collection.autoPK : true,
autoCreatedAt: hasOwnProperty(collection, 'autoCreatedAt') ? collection.autoCreatedAt : true,
autoUpdatedAt: hasOwnProperty(collection, 'autoUpdatedAt') ? collection.autoUpdatedAt : true
autoPK: defaultSettings.autoPK,
autoCreatedAt: defaultSettings.autoCreatedAt,
autoUpdatedAt: defaultSettings.autoUpdatedAt
};

@@ -103,0 +122,0 @@

{
"name": "waterline-schema",
"description": "The core schema builder used in the Waterline ORM.",
"version": "0.1.5",
"version": "0.1.6",
"contributors": [

@@ -6,0 +6,0 @@ {

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