diff --git a/js/common/tests/shell-foxx-repository.js b/js/common/tests/shell-foxx-repository.js index e3cc48c0b6..859e8ebf63 100644 --- a/js/common/tests/shell-foxx-repository.js +++ b/js/common/tests/shell-foxx-repository.js @@ -123,7 +123,7 @@ function RepositoryMethodsSpec() { .withArguments(modelData) .andReturn(id_and_rev); - instance.save(model); + assertEqual(instance.save(model), model); model.assertIsSatisfied(); collection.assertIsSatisfied(); @@ -167,7 +167,7 @@ function RepositoryMethodsSpec() { .withArguments(id, data) .andReturn(id_and_rev); - instance.replace(model); + assertEqual(instance.replace(model), model); collection.assertIsSatisfied(); model.assertIsSatisfied(); @@ -187,7 +187,7 @@ function RepositoryMethodsSpec() { .withArguments(id, data) .andReturn(id_and_rev); - instance.replaceById(id, model); + assertEqual(instance.replaceById(id, model), model); collection.assertIsSatisfied(); model.assertIsSatisfied(); diff --git a/js/server/modules/org/arangodb/foxx/repository.js b/js/server/modules/org/arangodb/foxx/repository.js index d0a9991494..c33ca50fe6 100644 --- a/js/server/modules/org/arangodb/foxx/repository.js +++ b/js/server/modules/org/arangodb/foxx/repository.js @@ -105,11 +105,13 @@ _.extend(Repository.prototype, { /// @brief Save a model into the database /// /// Expects a model. Will set the ID and Rev on the model. +/// Returns the model (for convenience). //////////////////////////////////////////////////////////////////////////////// save: function (model) { 'use strict'; var id_and_rev = this.collection.save(model.forDB()); model.set(id_and_rev); + return model; }, //////////////////////////////////////////////////////////////////////////////// @@ -140,6 +142,7 @@ _.extend(Repository.prototype, { /// /// Find the model in the database by its `_id` and replace it with this version. /// Expects a model. Sets the Revision of the model. +/// Returns the model (for convenience). //////////////////////////////////////////////////////////////////////////////// replace: function (model) { 'use strict'; @@ -147,6 +150,7 @@ _.extend(Repository.prototype, { data = model.forDB(), id_and_rev = this.collection.replace(id, data); model.set(id_and_rev); + return model; }, //////////////////////////////////////////////////////////////////////////////// @@ -156,12 +160,14 @@ _.extend(Repository.prototype, { /// Find the model in the database by the given ID and replace it with the given. /// model. /// Expects a model. Sets the ID and Revision of the model. +/// Returns the model (for convenience). //////////////////////////////////////////////////////////////////////////////// replaceById: function (id, model) { 'use strict'; var data = model.forDB(), id_and_rev = this.collection.replace(id, data); model.set(id_and_rev); + return model; }, ////////////////////////////////////////////////////////////////////////////////