Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ah-sequelize-plugin

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ah-sequelize-plugin - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

8

initializers/sequelize.js

@@ -26,3 +26,3 @@ var path = require('path');

var migrator = api.sequelize.sequelize.getMigrator({
path: api.project_root + '/migrations'
path: api.projectRoot + '/migrations'
});

@@ -49,3 +49,3 @@

var dir = path.normalize(api.project_root + '/models');
var dir = path.normalize(api.projectRoot + '/models');
fs.readdirSync(dir).forEach(function(file){

@@ -59,4 +59,4 @@ var nameParts = file.split("/");

var SequelizeFixtures = require('sequelize-fixtures');
SequelizeFixtures.loadFile(api.project_root + '/test/fixtures/*.json', api.models, function(){
SequelizeFixtures.loadFile(api.project_root + '/test/fixtures/*.yml', api.models, function(){
SequelizeFixtures.loadFile(api.projectRoot + '/test/fixtures/*.json', api.models, function(){
SequelizeFixtures.loadFile(api.projectRoot + '/test/fixtures/*.yml', api.models, function(){
self.test(next);

@@ -63,0 +63,0 @@ });

@@ -5,3 +5,3 @@ {

"description": "I use sequelize in actionhero as an ORM",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "http://actionherojs.com",

@@ -8,0 +8,0 @@ "repository": {

@@ -28,2 +28,4 @@ # ah-sequelize-plugin

Models are loaded into `api.models`, so the example above would be `api.models.Project`.
## [Migrations](http://sequelizejs.com/docs/latest/migrations)

@@ -33,2 +35,52 @@

An example migration to create a `users` table would look like:
```javascript
// from ./migrations/20140101000001-create-users.js
module.exports = {
up: function(migration, DataTypes, done) {
migration.createTable('users', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: DataTypes.STRING,
email: DataTypes.STRING,
phone: DataTypes.STRING,
passwordHash: DataTypes.TEXT,
passwordSalt: DataTypes.TEXT,
createdAt: DataTypes.DATE
updatedAt: DataTypes.DATE
}).complete(function(){
migration.addIndex('users', ['email'], {
indexName: 'email_index',
indicesType: 'UNIQUE'
}).complete(function(){
migration.addIndex('users', ['name'], {
indexName: 'name_index',
indicesType: 'UNIQUE'
}).complete(function(){
migration.addIndex('users', ['phone'], {
indexName: 'phone_index',
indicesType: 'UNIQUE'
}).complete(function(){
done();
});
});
});
});
},
down: function(migration, DataTypes, done) {
migration.dropTable('users').complete(done);
}
}
```
You can use the [sequelize-cli](http://sequelizejs.com/docs/latest/migrations#cli) for more utilities or

@@ -61,2 +113,4 @@ you can add a migration grunt helper(s) to your actionhero project by adding the below to your `gruntfile.js`:

If you want to sync, you can `api.sequelize.sync()` or `api.models.yourModel.sync()`;
## [Associations](http://sequelizejs.com/docs/latest/associations)

@@ -63,0 +117,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