diff --git a/docs/usage.md b/docs/usage.md index d7f892e2..09913607 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -92,8 +92,10 @@ console.log(models.instance.Person === MyModel); // sync the schema definition with the cassandra database table // if the schema has not changed, the callback will fire immediately // otherwise express-cassandra will try to migrate the schema and fire the callback afterwards -MyModel.syncDB(function(err) { +MyModel.syncDB(function(err, result) { if (err) throw err; + // result == true if any database schema was updated + // result == false if no schema change was detected in your models }); ``` diff --git a/src/orm/base_model.js b/src/orm/base_model.js index f699e184..04d3c051 100644 --- a/src/orm/base_model.js +++ b/src/orm/base_model.js @@ -157,7 +157,8 @@ BaseModel._sync_model_definition = function f(callback) { Promise.all(indexingTasks) .then(() => { - callback(); + // db schema was updated, so callback with true + callback(null, true); }) .catch((err2) => { callback(err2); @@ -185,7 +186,8 @@ BaseModel._sync_model_definition = function f(callback) { } if (_.isEqual(normalizedModelSchema, normalizedDBSchema)) { - callback(); + // no change in db was made, so callback with false + callback(null, false); return; }