Once you have correctly setup your Auroras and Collections, you can use the API below, from your controllers (in general).
[!!] The Au class is a shortcut to access the core API. Otherwise, you can decorate your Aurora_ class with the core methods, using Aurora::factory.
The core API methods are devided into 2 sets
-
The database API: loading/saving/deleting models.
-
The JSON API: JSON encoding and decoding.
Load a Model or a Collection from your database.
Example:
$person = Au::load('person', 1);
or
$person = Aurora::factory('person')->load(1);
Save a Model or a Collection to the database.
Example:
Au::save($person);
or
Aurora::factory('person')->save($person);
Delete a Model or a Collection from the database.
Example:
$person = Au::load('person', 1);
Au::delete($person);
or
Aurora::factory('person')->delete(1);
Encode your Model or your Collection to JSON. This returns a Kohana View.
Example:
// or
// $view = Aurora::factory('person')->json_encode($person);
$view = Au::json_encode($person);
$this->response->body($view->render());
Decode your Model or your Collection from JSON.
Example:
$person = Au::json_decode('person', $str_json);
or
$person = Aurora::factory('person')->json_decode($str_json);