masumsoft / express-cassandra

Cassandra ORM/ODM/OGM for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.
http://express-cassandra.readthedocs.io
GNU Lesser General Public License v3.0
227 stars 67 forks source link

support for async/await added in hook functions #194

Closed aaabhilash97 closed 4 years ago

aaabhilash97 commented 5 years ago

Support for async await

Now we can use hook functions like this

module.exports = {
    fields: {
        ...
    },
    key: [...],
    before_save: async  function (instance, options) {
        await Promise.all([]);
        return true;
    },
    after_save: function (instance, options) {
         return new Promise((resolve)=>{
             return resolve(true);         
        })
    },
    before_update: function (queryObject, updateValues, options) {
        return true;
    },
    after_update: function (queryObject, updateValues, options) {
        return true;
    },
    before_delete: function (queryObject, options) {
        return true;
    },
    after_delete: function (queryObject, options) {
        return true;
    },
}
JefferyHus commented 4 years ago

Why would you add the async/await to these functions?