feathers-sequelize
Advanced tools
Comparing version 3.0.1 to 3.0.2
# 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) |
{ | ||
"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 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96238
4
426
13
- Removedsequelize@^4.25.1
- Removed@types/geojson@1.0.6(transitive)
- Removed@types/node@22.5.4(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcls-bluebird@2.1.0(transitive)
- Removeddebug@2.6.93.2.7(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddottie@2.0.6(transitive)
- Removedgeneric-pool@3.5.0(transitive)
- Removedinflection@1.12.0(transitive)
- Removedis-bluebird@1.0.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmoment@2.30.1(transitive)
- Removedmoment-timezone@0.5.45(transitive)
- Removedms@2.0.0(transitive)
- Removedretry-as-promised@2.3.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedsequelize@4.44.4(transitive)
- Removedshimmer@1.2.1(transitive)
- Removedterraformer@1.0.12(transitive)
- Removedterraformer-wkt-parser@1.2.1(transitive)
- Removedtoposort-class@1.0.1(transitive)
- Removedundici-types@6.19.8(transitive)
- Removeduuid@3.4.0(transitive)
- Removedvalidator@10.11.0(transitive)
- Removedwkx@0.4.8(transitive)