Services
Robust service layer for ultimate flexibility.

CleverStack's Service Layer makes a clear distiction between web (controller) activity that is best handled in the controller and general business related logic that is not web related - this separation also gives us the ability to do testing on the business logic of the Service either on it's own (unit test) or with the web related logic from the Controller/s (e2e test)

Good code is short, simple, and symmetrical – the challenge is figuring out how to get there.
Sean Parent

A Service should take advantage of our Dependency Injection and load whatever Model is used to actually store the data, by defining the Model in the Class of the Service you are able to enable the Controller to automatically give you CRUD routing and actions.

Service nesting

When defining methods in services that require other models the correct way of working with those other models is to use their Service, this mean's that services business logic can still be run (transactions, their own transactions, etc)

Flexible persistence

Using a Service Layer also mean's that you can store data in whatever you want not just the ORM or ODM models that CleverStack provides, and you can even easily change the underlying storage of an existing Service because of this Pattern.

Needs more information

This section of the documentation is either out-dated or incomplete, please ask for help in github or hipchat if you need more information.

module.exports = function ( Service, ExampleModel ) {
    return Service.extend({
        model: ExampleModel
    });
};

Needs more information

This section of the documentation is either out-dated or incomplete, please ask for help in github or gitter if you need more information.

Needs more information

This section of the documentation is either out-dated or incomplete, please ask for help in github or gitter if you need more information.

Needs more information

This section of the documentation is either out-dated or incomplete, please ask for help in github or gitter if you need more information.

Needs more information

This section of the documentation is either out-dated or incomplete, please ask for help in github or gitter if you need more information.