Sails V1.5 blueprints for sequelize ORM V6 To be used with sails-hook-sequeliz
The blueprints waterline replaced with Sequelize.
Install sails-hook-sequeliz first:
$ npm install sails-hook-sequeliz --save
Install this hook with:
$ npm install sails-hook-sequeliz-blueprints --save
Sequelize dependencies:
$ npm install --save sequelize
$ npm install --save cls-hooked
.sailsrc
"hooks": {
"blueprints": false,
"orm": false,
"pubsub": false
}
Default blueprints configurations config/blueprints.js
module.exports.blueprints = {
actions: true,
shortcuts: true,
rest: true,
autoWatch: true,
}
Include in package.json git reference to this package (see following example)
{
"name": "test",
"private": true,
"version": "0.0.0",
"description": "application",
"keywords": [],
"dependencies": {
"@babel/preset-env": "7.15.6",
"sails": "^1.5.0",
"sails-disk": "~2.1.0",
"sails-hook-cron": "^3.2.0",
"sails-hook-grunt": "^5.0.0",
"sails-hook-sequelize": "git://github.com/aristot/sails-hook-sequeliz",
"sails-hook-sequeliz-blueprints": "git://github.com/aristot/sails-hook-sequeliz-blueprints",
"sails-hook-sockets": "2.0.1",
"sails-hook-validation": "^0.4.7",
"sequelize": "^6.6.5",
"sequelize-cli": "^6.2.0",
"tedious": "^12.2.0",
},
"repository": {
},
"devDependencies": {
},
"config": {
"grunt": "./node_modules/sails/node_modules/.bin/grunt"
},
"main": "app.js",
"license": "MIT",
"engines": {
"node": "~14.17.x",
"npm": "~7.20.x"
}
}
Sequelize connection with sqlserver 2019 Express
Sequelize model definition
models/user.js
module.exports = {
attributes: {
name: {
type: Sequelize.STRING,
allowNull: false
},
age: {
type: Sequelize.INTEGER
}
},
associations: function() {
user.hasMany(image, {
foreignKey: {
name: 'owner',
allowNull: false
}
});
user.belongsToMany(affiliation, {
as: 'affiliations',
to: 'users', // must be named as the alias in the related Model
through: 'UserAffiliation',
foreignKey: {
name: 'userId',
as: 'affiliations'
}
});
},
options: {
tableName: 'user',
classMethods: {},
instanceMethods: {},
hooks: {}
}
};
This is an experimental hook developed by Raymond FEST from ARISTOT compagny and tested with sqlServer 2019 database populate is disabled reduce usage of lodash
A big thanks to festo/sailsjs-sequelize-example and Manuel Darveau's answer that turn this possible with thier sequelize implementations.
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -m 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request