feathers-sequelize
Advanced tools
Comparing version 3.1.2 to 3.1.3
# Change Log | ||
## [v3.1.2](https://github.com/feathersjs-ecosystem/feathers-sequelize/tree/v3.1.2) (2018-06-07) | ||
[Full Changelog](https://github.com/feathersjs-ecosystem/feathers-sequelize/compare/v3.1.1...v3.1.2) | ||
**Fixed bugs:** | ||
- `Paginate` option for a feathers-sequelize service is not working as expected [\#186](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/186) | ||
**Closed issues:** | ||
- options object extra data lost [\#209](https://github.com/feathersjs-ecosystem/feathers-sequelize/issues/209) | ||
**Merged pull requests:** | ||
- Default paginate option value set to false instead of empty object [\#217](https://github.com/feathersjs-ecosystem/feathers-sequelize/pull/217) ([alex-friedl](https://github.com/alex-friedl)) | ||
- keeping options data with the service [\#216](https://github.com/feathersjs-ecosystem/feathers-sequelize/pull/216) ([pyvkd](https://github.com/pyvkd)) | ||
## [v3.1.1](https://github.com/feathersjs-ecosystem/feathers-sequelize/tree/v3.1.1) (2018-06-03) | ||
@@ -4,0 +20,0 @@ [Full Changelog](https://github.com/feathersjs-ecosystem/feathers-sequelize/compare/v3.1.0...v3.1.1) |
@@ -243,2 +243,3 @@ const omit = require('lodash.omit'); | ||
// update | ||
const updateOptions = Object.assign({ raw: false }, params.sequelize); | ||
@@ -259,3 +260,3 @@ return this._get(id, { sequelize: { raw: false }, query: where }).then(instance => { | ||
return instance.update(copy, {raw: false}).then(() => this._get(id, {sequelize: options})); | ||
return instance.update(copy, updateOptions).then(() => this._get(id, {sequelize: options})); | ||
}) | ||
@@ -262,0 +263,0 @@ .then(select(params, this.id)) |
{ | ||
"name": "feathers-sequelize", | ||
"description": "A service adapter for Sequelize an SQL ORM", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"homepage": "https://github.com/feathersjs-ecosystem/feathers-sequelize", | ||
@@ -6,0 +6,0 @@ "main": "lib/", |
@@ -21,3 +21,3 @@ # feathers-sequelize | ||
npm install --save pg pg-hstore | ||
npm install --save mysql // For both mysql and mariadb dialects | ||
npm install --save mysql2 // For both mysql and mariadb dialects | ||
npm install --save sqlite3 | ||
@@ -62,6 +62,9 @@ npm install --save tedious // MSSQL | ||
const sequelize = context.app.get('sequelizeClient'); | ||
const { User } = sequelize.models; | ||
context.params.sequelize = { | ||
include: [ User ] | ||
} | ||
return context; | ||
} | ||
@@ -74,3 +77,3 @@ } | ||
By default, all `feathers-sequelize` operations will return `raw` data (using `raw: true` when querying the database). This results in faster execution and allows feathers-sequelize to interoperate with feathers-common hooks and other 3rd party integrations. However, this will bypass some of the "goodness" you get when using Sequelize as an ORM: | ||
By default, all `feathers-sequelize` operations will return `raw` data (using `raw: true` when querying the database). This results in faster execution and allows feathers-sequelize to interoperate with feathers-common hooks and other 3rd party integrations. However, this will bypass some of the "goodness" you get when using Sequelize as an ORM: | ||
@@ -81,3 +84,3 @@ - custom getters/setters will be bypassed | ||
- ...and several other issues that one might not expect | ||
Don't worry! The solution is easy. Please read the guides about [working with model instances](#working-with-sequelize-model-instances). | ||
@@ -219,3 +222,3 @@ | ||
hooks.after.find = [hydrate()]; | ||
// Or, if you need to include associated models, you can do the following: | ||
@@ -237,6 +240,6 @@ function includeAssociated (context) { | ||
> const { populate } = require('feathers-hooks-common'); | ||
> | ||
> | ||
> hooks.after.find = [hydrate(), doSomethingCustom(), dehydrate(), populate()]; | ||
> ``` | ||
## Validation | ||
@@ -284,3 +287,3 @@ | ||
context.params.sequelize = { | ||
/* | ||
/* | ||
* This is the same object you passed to "findAll" above. | ||
@@ -325,13 +328,13 @@ * This object is *shallow merged* onto the underlying query object | ||
module.exports = { | ||
'config': path.resolve('migrations/config/config.js'), | ||
'migrations-path': path.resolve('migrations'), | ||
'config': path.resolve('migrations/config.js'), | ||
'migrations-path': path.resolve('migrations/scripts'), | ||
'seeders-path': path.resolve('migrations/seeders'), | ||
'models-path': path.resolve('migrations/models') | ||
'models-path': path.resolve('migrations/models.js') | ||
}; | ||
``` | ||
- Create the migrations config in `migrations/config/config.js`: | ||
- Create the migrations config in `migrations/config.js`: | ||
```js | ||
const app = require('../../src/app'); | ||
const app = require('../src/app'); | ||
const env = process.env.NODE_ENV || 'development'; | ||
@@ -349,7 +352,7 @@ const dialect = 'mysql'|'sqlite'|'postgres'|'mssql'; | ||
- Define your models config in `migrations/models/index.js`: | ||
- Define your models config in `migrations/models.js`: | ||
```js | ||
const Sequelize = require('sequelize'); | ||
const app = require('../../src/app'); | ||
const app = require('../src/app'); | ||
const sequelize = app.get('sequelizeClient'); | ||
@@ -368,3 +371,3 @@ const models = sequelize.models; | ||
The migration commands will load your application and it is therefore required that you define the same environment variables as when running you application. For example, many applications will define the database connection string in the startup command: | ||
The migration commands will load your application and it is therefore required that you define the same environment variables as when running your application. For example, many applications will define the database connection string in the startup command: | ||
@@ -390,5 +393,5 @@ ``` | ||
This will create a new file in the migrations folder. All migration file names will be prefixed with a sortable data/time string: `20160421135254-meaninful-name.js`. This prefix is crucial for making sure your migrations are executed in the proper order. | ||
This will create a new file in the `migrations/scripts` folder. All migration file names will be prefixed with a sortable data/time string: `20160421135254-meaningful-name.js`. This prefix is crucial for making sure your migrations are executed in the proper order. | ||
> **NOTE:** The order of your migrations is determined by the alphabetical order of the migration scripts in the file system. The file names generated by the CLI tools will always ensure that the most recent migration comes last. | ||
> **NOTE:** The order of your migrations is determined by the alphabetical order of the migration scripts in the file system. The file names generated by the CLI tools will always ensure that the most recent migration comes last. | ||
@@ -420,3 +423,3 @@ #### Add the up/down scripts: | ||
> **ProTip:** As of this writing, if you use the `changeColumn` method you must **always** specify the `type`, even if the type is not changing. | ||
> **ProTip:** Down scripts are typically easy to create and should be nearly identical to the up script except with inverted logic and inverse method calls. | ||
@@ -458,3 +461,3 @@ | ||
``` | ||
sequelize db:migrate | ||
sequelize db:migrate | ||
``` | ||
@@ -475,3 +478,3 @@ | ||
``` | ||
sequelize db:migrate:undo | ||
sequelize db:migrate:undo | ||
``` | ||
@@ -491,3 +494,3 @@ | ||
1. Undo your migrations one at a time until the db is in the correct state | ||
1. Revert your code back to the previous state | ||
1. Revert your code back to the previous state | ||
1. Start your app | ||
@@ -494,0 +497,0 @@ |
Sorry, the diff of this file is not supported yet
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
102546
377
488