Model - Atileon/OC-p8 Wiki

Overview

This module iterates with the Storage and executes CRUD principles

Below will follow the methods for CRUD operations

Model.create

Creates a new todo model

Model.create

Model.read

Finds and returns a model in storage. If no query is given it'll simply return everything. If you pass in a string or number it'll look that up as the ID of the model to find. Lastly, you can pass it an object to match against.

@example

model.read(1, func); // Will find the model with an ID of 1

model.read('1'); // Same as above

//Below will find a model with foo equalling bar and hello equalling world.

model.read({ foo: 'bar', hello: 'world' });

Model.read

Model.update

Updates a model by giving it an ID, data to update, and a callback to fire when the update is complete.

Model.update

Model.remove

Removes a model from storage

Model.remove

Model.removeAll

WARNING: Will remove ALL data from storage.

Model.removeAll

Previous < The App (How it Works) -------/-------/------- Next > View