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 3.0.1 to 3.0.2

14

CHANGELOG.md
# Change Log
## [v3.0.1](https://github.com/feathersjs-ecosystem/feathers-sequelize/tree/v3.0.1) (2018-03-07)
[Full Changelog](https://github.com/feathersjs-ecosystem/feathers-sequelize/compare/v3.0.0...v3.0.1)
**Closed issues:**
- `raw: false,` does not work with with Buzzard [\#184](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/184)
- "error: NotFound: No record found for id" when calling with socket.io [\#179](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/179)
**Merged pull requests:**
- Add default ES module export for TS compatibility [\#190](https://github.com/feathersjs-ecosystem/feathers-sequelize/pull/190) ([Bubomir](https://github.com/Bubomir))
- Update mocha to the latest version 🚀 [\#187](https://github.com/feathersjs-ecosystem/feathers-sequelize/pull/187) ([greenkeeper[bot]](https://github.com/apps/greenkeeper))
- Update semistandard to the latest version 🚀 [\#185](https://github.com/feathersjs-ecosystem/feathers-sequelize/pull/185) ([greenkeeper[bot]](https://github.com/apps/greenkeeper))
## [v3.0.0](https://github.com/feathersjs-ecosystem/feathers-sequelize/tree/v3.0.0) (2017-12-04)

@@ -4,0 +18,0 @@ [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-sequelize/compare/v2.4.0...v3.0.0)

6

package.json
{
"name": "feathers-sequelize",
"description": "A service adapter for Sequelize an SQL ORM",
"version": "3.0.1",
"version": "3.0.2",
"homepage": "https://github.com/feathersjs-ecosystem/feathers-sequelize",

@@ -63,3 +63,2 @@ "main": "lib/",

"lodash.omit": "^4.3.0",
"sequelize": "^4.25.1",
"uberproto": "^1.1.2"

@@ -79,4 +78,5 @@ },

"semistandard": "^12.0.0",
"sqlite3": "^3.1.7"
"sequelize": "^4.36.1",
"sqlite3": "^4.0.0"
}
}

@@ -11,2 +11,4 @@ # feathers-sequelize

> __Very Important:__ Before using this adapter you have to be familiar with both, the [Feathers Basics](https://docs.feathersjs.com/guides/basics/readme.html) and general use of [Sequelize](http://docs.sequelizejs.com/). For associations and relations see the [associations](#associations) section. This adapter may not cover all use cases but they can still be implemented using Sequelize models directly in a [Custom Feathers service](https://docs.feathersjs.com/guides/basics/services.html).
```bash

@@ -26,3 +28,2 @@ npm install --save feathers-sequelize

> __Important:__ `feathers-sequelize` implements the [Feathers Common database adapter API](https://docs.feathersjs.com/api/databases/common.html) and [querying syntax](https://docs.feathersjs.com/api/databases/querying.html).
> For more information about models and general Sequelize usage, follow up in the [Sequelize documentation](http://docs.sequelizejs.com/en/latest/).

@@ -155,14 +156,45 @@

## Querying
## Associations
Additionally to the [common querying mechanism](https://docs.feathersjs.com/api/databases/querying.html) this adapter also supports all [Sequelize query operators](http://docs.sequelizejs.com/manual/tutorial/querying.html).
### Embrace the ORM
> **Note**: This adapter supports an additional `$returning` parameter for patch and remove queries. By setting `params.$returning = false` it will disable feathers and sequelize from returning what was changed, so mass updates can be done without overwhelming node and/or clients.
The documentation on [Sequelize associations and relations](http://docs.sequelizejs.com/manual/tutorial/associations.html) is essential to implementing associations with this adapter and one of the steepest parts of the Sequelize learning curve. If you have never used an ORM, let it do a lot of the heavy lifting for you!
### Setting `params.sequelize.include`
Once you understand how the `include` option works with Sequelize, you will want to set that option from a [before hook](https://docs.feathersjs.com/guides/basics/hooks.html) in Feathers. Feathers will pass the value of `context.params.sequelize` as the options parameter for all Sequelize method calls. This is what your hook might look like:
## Associations and relations
```js
// GET /my-service?name=John&include=1
function (context) {
if (hook.params.query.include) {
const AssociatedModel = hook.app.services.fooservice.Model;
hook.params.sequelize = {
include: [{ model: AssociatedModel }]
};
// delete any special query params so they are not used
// in the WHERE clause in the db query.
delete context.params.query.include;
}
Follow up in the [Sequelize documentation for associations](http://docs.sequelizejs.com/manual/tutorial/associations.html), [this issue](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/20) and [this Stackoverflow answer](https://stackoverflow.com/questions/42841810/feathers-js-sequelize-service-with-relations-between-two-models/42846215#42846215).
return Promise.resolve(context);
}
```
Underneath the hood, feathers will call your models find method sort of like this:
```js
// YourModel is a sequelize model
const options = Object.assign({ where: { name: 'John' }}, context.params.sequelize);
YourModel.findAndCount(options);
```
For more information, follow up up in the [Sequelize documentation for associations](http://docs.sequelizejs.com/manual/tutorial/associations.html)and [this issue](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/20).
## Querying
Additionally to the [common querying mechanism](https://docs.feathersjs.com/api/databases/querying.html) this adapter also supports all [Sequelize query operators](http://docs.sequelizejs.com/manual/tutorial/querying.html).
> **Note**: This adapter supports an additional `$returning` parameter for patch and remove queries. By setting `params.$returning = false` it will disable feathers and sequelize from returning what was changed, so mass updates can be done without overwhelming node and/or clients.
## Working with Sequelize Model instances

@@ -280,3 +312,3 @@

> ```
```
export DATABASE_URL=postgres://user:pass@host:port/db

@@ -283,0 +315,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