Book Image

Knockout.JS Essentials

Book Image

Knockout.JS Essentials

Overview of this book

Table of Contents (16 chapters)
KnockoutJS Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Defining CRUD


When you define a service to send and receive data, this object should usually perform a minimum level of behavior. You can identify this behavior through the acronym CRUD:

  • Create (C): You need to send a message to the server with a new object to persist it in a database. The HTTP POST verb is used for such requests.

  • Retrieve (R): The service should be able to send a request to get a collection of objects or just one specific object. The GET verb is used for such requests.

  • Update (U): This is a request to update an object. By convention, the PUT verb is used for such requests.

  • Delete (D): This is a request to delete an object. The DELETE verb is used for such requests.

More operations can be implemented, and sometimes you do not need to code all CRUD methods. You should adapt your code to the application requirements and define only operations that the application needs. Remember that writing more code than the application needs means creating the possibility of writing more...