Socket
Socket
Sign inDemoInstall

feathers-sequelize

Package Overview
Dependencies
Maintainers
2
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feathers-sequelize - npm Package Compare versions

Comparing version 1.4.5 to 2.0.0

lib/hooks/dehydrate.js

7

CHANGELOG.md
# Change Log
## [v1.4.5](https://github.com/feathersjs/feathers-sequelize/tree/v1.4.5) (2017-03-26)
[Full Changelog](https://github.com/feathersjs/feathers-sequelize/compare/v1.4.4...v1.4.5)
**Merged pull requests:**
- Fix update no dao [\#101](https://github.com/feathersjs/feathers-sequelize/pull/101) ([lowip](https://github.com/lowip))
## [v1.4.4](https://github.com/feathersjs/feathers-sequelize/tree/v1.4.4) (2017-03-24)

@@ -4,0 +11,0 @@ [Full Changelog](https://github.com/feathersjs/feathers-sequelize/compare/v1.4.3...v1.4.4)

78

lib/index.js

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

this.events = options.events;
this.raw = options.raw !== false;
}

@@ -83,3 +84,4 @@

limit: filters.$limit,
offset: filters.$skip
offset: filters.$skip,
raw: this.raw
}, params.sequelize);

@@ -119,3 +121,3 @@

value: function _get(id, params) {
var promise = void 0;
var promise = undefined;

@@ -127,3 +129,5 @@ if (params.sequelize && params.sequelize.include) {

// Attach 'where' constraints, if any were used.
var q = _extends({ where: _extends({ id: id }, where) }, params.sequelize);
var q = _extends({
where: _extends({ id: id }, where)
}, params.sequelize);

@@ -138,3 +142,4 @@ promise = this.Model.findAll(q).then(function (result) {

} else {
promise = this.Model.findById(id, params.sequelize).then(function (instance) {
var options = _extends({ raw: this.raw }, params.sequelize);
promise = this.Model.findById(id, options).then(function (instance) {
if (!instance) {

@@ -173,9 +178,26 @@ throw new _feathersErrors2.default.NotFound('No record found for id \'' + id + '\'');

value: function create(data, params) {
var options = params.sequelize || {};
var _this = this;
if (Array.isArray(data)) {
return this.Model.bulkCreate(data, options).catch(utils.errorHandler);
var options = _extends({ raw: this.raw }, params.sequelize);
var isArray = Array.isArray(data);
var promise = undefined;
if (isArray) {
promise = this.Model.bulkCreate(data, options);
} else {
promise = this.Model.create(data, options);
}
return this.Model.create(data, options).then((0, _feathersCommons.select)(params, this.id)).catch(utils.errorHandler);
return promise.then(function (result) {
var sel = (0, _feathersCommons.select)(params, _this.id);
if (options.raw === false) {
return result;
}
if (isArray) {
return result.map(function (item) {
return sel(item.toJSON());
});
}
return sel(result.toJSON());
}).catch(utils.errorHandler);
}

@@ -185,3 +207,3 @@ }, {

value: function patch(id, data, params) {
var _this = this;
var _this2 = this;

@@ -191,3 +213,3 @@ var where = _extends({}, (0, _feathersQueryFilters2.default)(params.query || {}).query);

return page.data.map(function (current) {
return current[_this.id];
return current[_this2.id];
});

@@ -206,3 +228,11 @@ };

return this.Model.update((0, _lodash2.default)(data, this.id), options).then(function (results) {
return results[1];
if (id === null) {
return results[1];
}
if (!results[1].length) {
throw new _feathersErrors2.default.NotFound('No record found for id \'' + id + '\'');
}
return results[1][0];
}).then((0, _feathersCommons.select)(params, this.id)).catch(utils.errorHandler);

@@ -220,7 +250,7 @@ }

var findParams = _extends({}, params, {
query: _defineProperty({}, _this.id, { $in: idList })
query: _defineProperty({}, _this2.id, { $in: idList })
});
return _this.Model.update((0, _lodash2.default)(data, _this.id), options).then(function () {
return _this._getOrFind(id, findParams);
return _this2.Model.update((0, _lodash2.default)(data, _this2.id), options).then(function () {
return _this2._getOrFind(id, findParams);
});

@@ -232,6 +262,6 @@ }).then((0, _feathersCommons.select)(params, this.id)).catch(utils.errorHandler);

value: function update(id, data, params) {
var options = _extends({}, params.sequelize);
var options = _extends({ raw: this.raw }, params.sequelize);
if (Array.isArray(data)) {
return Promise.reject('Not replacing multiple records. Did you mean `patch`?');
return Promise.reject(new _feathersErrors2.default.BadRequest('Not replacing multiple records. Did you mean `patch`?'));
}

@@ -255,3 +285,8 @@

return instance.update(copy, options);
return instance.update(copy, options).then(function (instance) {
if (options.raw === false) {
return instance;
}
return instance.toJSON();
});
}).then((0, _feathersCommons.select)(params, this.id)).catch(utils.errorHandler);

@@ -262,9 +297,10 @@ }

value: function remove(id, params) {
var _this2 = this;
var _this3 = this;
return this._getOrFind(id, params).then(function (data) {
var opts = _extends({ raw: this.raw }, params);
return this._getOrFind(id, opts).then(function (data) {
var where = _extends({}, (0, _feathersQueryFilters2.default)(params.query || {}).query);
if (id !== null) {
where[_this2.id] = id;
where[_this3.id] = id;
}

@@ -274,3 +310,3 @@

return _this2.Model.destroy(options).then(function () {
return _this3.Model.destroy(options).then(function () {
return data;

@@ -277,0 +313,0 @@ });

{
"name": "feathers-sequelize",
"description": "A service adapter for Sequelize an SQL ORM",
"version": "1.4.5",
"version": "2.0.0",
"homepage": "https://github.com/feathersjs/feathers-sequelize",

@@ -79,7 +79,7 @@ "main": "lib/",

"feathers-rest": "^1.3.0",
"feathers-service-tests": "^0.9.0",
"feathers-service-tests": "^0.10.0",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^3.0.0",
"rimraf": "^2.5.4",
"semistandard": "^9.1.0",
"semistandard": "^11.0.0",
"sequelize": "^3.25.0",

@@ -86,0 +86,0 @@ "sqlite3": "^3.1.7"

# feathers-sequelize
[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/feathers-sequelize.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/feathersjs/feathers-sequelize.png?branch=master)](https://travis-ci.org/feathersjs/feathers-sequelize)

@@ -4,0 +6,0 @@ [![Code Climate](https://codeclimate.com/github/feathersjs/feathers-sequelize.png)](https://codeclimate.com/github/feathersjs/feathers-sequelize)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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