Merged PetitTetonApps with the website now that the deployment server always uses SSL. Used the Apps more recent implementation of NodeJS/Express.
This commit is contained in:
33
app/models/sale.js
Normal file
33
app/models/sale.js
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
//The id field is auto added and made primary key.
|
||||
var Sale = sequelize.define('Sale', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
autoIncrement: true
|
||||
},
|
||||
date: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false
|
||||
},
|
||||
measure: {
|
||||
type: DataTypes.JSONB,
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
freezeTableName: true, // Model tableName will be the same as the model name
|
||||
classMethods: {
|
||||
associate: function(models) {
|
||||
//Sale.hasOne(models.Category, {as: 'category'});
|
||||
//Sale.hasOne(models.Subcategory, {as: 'subcategory'});
|
||||
Sale.belongsTo(models.Item, {as: 'item', foreignKey: {name: 'itemId', field: 'itemId'}});
|
||||
Sale.belongsTo(models.Venue, {as: 'venue', foreignKey: {name: 'venueId', field: 'venueId'}});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Sale;
|
||||
};
|
||||
Reference in New Issue
Block a user