Created
March 18, 2017 03:47
-
-
Save banyudu/5c6961ca7d50b8e5be8a0d504a2d3dcb to your computer and use it in GitHub Desktop.
Sequelize model integrates with cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('fs'); | |
module.exports = function(sequelize, DataTypes) { | |
const tableName = 'something'; | |
const attr = JSON.parse(fs.readFileSync(__dirname + `/attributes/${tableName}`)); | |
const Something = sequelize.define('Something',attr, { | |
classMethods: { | |
getCacheFields: () => { return ['field1', 'field2', 'field3'] } // fields you want to cache | |
}, | |
tableName: tableName, | |
underscored: true, | |
createdAt: false, | |
updatedAt: false | |
}); | |
return Something; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment