Skip to content

Commit

Permalink
Merge pull request #96 from paparomeo/support-latest-jsonapi-server
Browse files Browse the repository at this point in the history
Support latest `jsonapi-server`.
  • Loading branch information
pmcnr-hx authored Dec 12, 2017
2 parents 61c160a + ec404ae commit a107729
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 392 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- 2017-12-12 - v5.0.0
- 2017-12-12 - Support latest version of `jsonapi-server` with store managed id support.
- 2017-12-12 - Revert column type for `string` properties back to `string` from `text`.
- 2017-12-12 - Remove support for Node.js 4.
- 2017-10-09 - v4.0.0
- 2017-10-09 - Optimised Sequelize UUID column type for ids.
- 2017-10-02 - v3.0.0
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
[![Code Climate](https://codeclimate.com/github/holidayextras/jsonapi-store-relationaldb/badges/gpa.svg)](https://codeclimate.com/github/holidayextras/jsonapi-store-relationaldb)
[![Dependencies Status](https://david-dm.org/holidayextras/jsonapi-store-relationaldb.svg)](https://david-dm.org/holidayextras/jsonapi-store-relationaldb)


# jsonapi-store-relationaldb

#### :warning: PLEASE NOTE: Version 4.x releases erroneously created columns for `string` properties as Sequelize `text` type. The behaviour in version 5.x has reverted back to creating columns with the Sequelize `string` type, which is the more adequate type and was the behaviour in versions 3.x and older. The `text` columns created by version 4.x will need to be manually migrated to `string` columns.

`jsonapi-store-relationaldb` is a relational database backed data store for [`jsonapi-server`](https://github.com/holidayextras/jsonapi-server).

This project conforms to the specification laid out in the [jsonapi-server handler documentation](https://github.com/holidayextras/jsonapi-server/blob/master/documentation/handlers.md).
Expand Down
9 changes: 8 additions & 1 deletion lib/modelGenerators/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = class {
const attribute = joiSchema[attributeName]
if (attribute._type === 'string') {
this[attributeName] = {
type: DataTypes.TEXT,
type: DataTypes.STRING,
allowNull: true
}
}
Expand Down Expand Up @@ -68,6 +68,13 @@ module.exports = class {
}
}
}
if (attributeName === 'id') {
delete this[attributeName].allowNull
Object.assign(this[attributeName], {
type: DataTypes.STRING(128),
primaryKey: true
})
}
}
}
}
Loading

0 comments on commit a107729

Please sign in to comment.