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

clever-orm

Package Overview
Dependencies
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clever-orm - npm Package Compare versions

Comparing version 2.0.0-rc2 to 2.0.0

bin/postInstall.js

10

bin/rebase.js

@@ -25,12 +25,2 @@ 'use strict';

[
function createDatabase(callback) {
var query = 'CREATE DATABASE ' + (config['clever-orm'].db.options.dialect === 'mysql' ? 'IF NOT EXISTS ' : '') + config['clever-orm'].db.database;
sequelize.query(query, { raw: true })
.then(function() {
callback(null);
})
.catch(callback);
},
function rebaseDatabase(callback) {

@@ -37,0 +27,0 @@ sequelize

2

bin/seedModels.js

@@ -102,3 +102,3 @@ 'use strict';

required.forEach(function(requiredModels) {
if (typeof requiredModels !== 'array') {
if (!(requiredModels instanceof Array)) {
requiredModels = [requiredModels];

@@ -105,0 +105,0 @@ }

'use strict';
var fs = require('fs')
, path = require('path')
, pkgJson = require(path.resolve(path.join(__dirname, '..', '..', 'package.json')))
, odmEnabled = pkgJson.bundledDependencies.indexOf('clever-odm') !== -1
, _ = require('underscore');
var fs = require('fs')
, path = require('path')
, appRoot = path.resolve(path.join(__dirname, '..', '..'))
, pkgJson = require(path.resolve(path.join(appRoot, 'package.json')))
, odmEnabled = pkgJson.bundledDependencies.indexOf('clever-odm') !== -1
, underscore = require('underscore');

@@ -13,3 +14,4 @@ module.exports = function(grunt) {

, config = {}
, dbTarget = grunt.option('module') || null;
, dbTarget = grunt.option('module') || null
, verbose = grunt.option('verbose');

@@ -36,8 +38,8 @@ return [{

filter: function(env) {
_.extend(config, defaultConfig);
underscore.extend(config, defaultConfig);
configFile = path.resolve(path.join(__dirname, '..', '..', 'config', env.toLowerCase() + '.json'));
configFile = path.resolve(path.join(appRoot, 'config', env.toLowerCase() + '.json'));
if (fs.existsSync(configFile)) {
_.extend(config, require(configFile));
underscore.extend(config, require(configFile));

@@ -90,3 +92,3 @@ Object.keys(defaultConfig['clever-orm']).forEach(function(key) {

default: function() {
return config['clever-orm'].db.dialect || 'mysql';
return config['clever-orm'].db.options.dialect || 'mysql';
}

@@ -99,3 +101,3 @@ },

default: function() {
return config['clever-orm'].db.host || '127.0.0.1';
return config['clever-orm'].db.options.host || '127.0.0.1';
}

@@ -108,4 +110,4 @@ },

default: function(answers) {
var dialect = config['clever-orm'].db.dialect
, port = config['clever-orm'].db.port;
var dialect = config['clever-orm'].db.options.dialect
, port = config['clever-orm'].db.options.port;

@@ -148,3 +150,7 @@ if (dialect && dialect !== answers['cleverstackorm.dialect']) {

cmd: "node modules/clever-orm/bin/seedModels.js " + dbTarget
}
},
ormPostInstall: {
cmd: "node modules/clever-orm/bin/postInstall.js " + (verbose ? '-v' : '')
},
}

@@ -171,12 +177,4 @@ }, function(grunt) {

// grunt.registerTask('readme', 'Displays helpful information', function () {
// console.log('(Manual) Installation instructions:');
// console.log('1. In the config file for your desired environment (ie. backend/config/local.json), update the clever-orm object with the details for your database.');
// console.log('');
// console.log('2. From your project\'s `backend` folder, run `NODE_ENV=local grunt db`.');
// console.log('The database tables for your modules should now be installed and seeded with data!');
// });
grunt.registerTask('prompt:cleverOrmConfig', ['prompt:cleverOrmConfigPrompt', 'cleverOrmCreateConfig']);
grunt.registerTask('cleverOrmCreateConfig', 'Creates a .json config file for database credentials', function () {
grunt.registerTask('prompt:cleverOrmConfig', ['prompt:cleverOrmConfigPrompt', 'cleverOrmCreateConfig', 'exec:ormPostInstall']);
grunt.registerTask('cleverOrmCreateConfig', 'Creates a .json config file for database credentials', function createOrmConfig() {
var conf = grunt.config('cleverstackorm')

@@ -188,3 +186,3 @@ , obj = require(path.resolve(path.join(process.cwd(), 'modules', 'clever-orm', 'config', 'default.json')))

if (fs.existsSync(file)) {
obj = _.extend(obj, require(file));
obj = underscore.extend(obj, require(file));
}

@@ -191,0 +189,0 @@

'use strict';
module.exports = function createRelation() {
var injector = require('injector')
, Promise = injector.getInstance('Promise');
module.exports = function createRelationAccessor(accessor, alias, TargetModel, values, options) {
return new Promise(function createRelation(resolve, reject) {
this
.entity[accessor](values, options)
.then(this.proxy(function(entity) {
if (this.entity[alias]) {
this.entity[alias].entity = entity;
}
resolve(this);
}))
.catch(reject);
}
.bind(this));
}

@@ -6,6 +6,6 @@ 'use strict';

module.exports = function getRelationAccessor(accessor, alias, TargetModel, where, options) {
module.exports = function getRelationAccessor(accessor, alias, TargetModel, findOptions, options) {
return new Promise(function getRelation(resolve, reject) {
this
.entity[accessor](where, options)
.entity[accessor](findOptions, options)
.then(this.proxy(function hydrate(entity) {

@@ -12,0 +12,0 @@ var instances;

@@ -7,3 +7,3 @@ var path = require('path')

, create = require(path.resolve(path.join(__dirname, 'create')))
, remove = require(path.resolve(path.join(__dirname, 'remove')));
, accessor = require(path.resolve(path.join(__dirname, 'default')));

@@ -65,4 +65,3 @@ function defineAssociationAccessors(sourceModel, assocType, targetModel, alias, association) {

setSingular : set,
// createSingular : create,
// removeSingular : remove
createSingular : create
},

@@ -72,4 +71,3 @@ belongsTo: {

setSingular : set,
// createSingular : create,
// removeSingular : remove
createSingular : create
},

@@ -79,10 +77,10 @@ hasMany: {

setPlural : set,
// createSingular : create,
// removeSingular : remove,
addSingular : require(path.resolve(path.join(__dirname, 'addSingular'))),
// hasPlural : require(path.resolve(path.join(__dirname, 'hasAll'))),
// hasSingular : require(path.resolve(path.join(__dirname, 'hasSingle'))),
// addPlural : require(path.resolve(path.join(__dirname, 'addMultiple'))),
// removePlural : require(path.resolve(path.join(__dirname, 'removeMultiple')))
createSingular : create,
removeSingular : get,
removePlural : get,
addSingular : accessor,
addPlural : accessor,
hasPlural : accessor,
hasSingular : accessor
}
}

@@ -6,5 +6,5 @@ 'use strict';

module.exports = function setRelationAccessor(accessor, alias, TargetModel, where, options) {
module.exports = function setRelationAccessor(accessor, alias, TargetModel, associatedObject, options) {
return new Promise(function setRelation(resolve, reject) {
var promise = this.entity[accessor](where, options);
var promise = this.entity[accessor](associatedObject, options);

@@ -11,0 +11,0 @@ if (!options || options.save !== false) {

@@ -11,2 +11,3 @@ 'use strict';

function defineAssociations(models) {
/*jshint validthis: true */
var cleverOrm = this

@@ -13,0 +14,0 @@ , modelNames = Object.keys(models);

@@ -11,2 +11,3 @@ 'use strict';

function defineNestedOperations(sourceModel, assocType, targetModel, alias, association) {
/*jshint validthis: true */
var events = this[assocType]

@@ -13,0 +14,0 @@ , eventNames;

{
"name": "clever-orm",
"description": "CleverStack ORM (SQL) Module",
"version": "2.0.0-rc2",
"version": "2.0.0",
"main": "module.js",

@@ -38,3 +38,2 @@ "author": {

"dependencies": {
"mysql": "2.0.0-rc2",
"sequelize": "2.0.3"

@@ -41,0 +40,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