Building the storage object
Then we’re ready for our createTable and addSampleData methods
Ok, so we’ve created the methods that will create/open our database and add some sample data – of course you can’t test this yet as the methods in this file will be called from our main app.js file we have yet to create. Stay with me though, abstracting the storage functionality like this makes things much easier further down the line. Lets continue and add the methods we’ll use to list all outstanding todos and get individual todos.
Next lets add some basic CRUD operations.
Also we need methods for marking a record as completed or pending, lets add those in now.
Finally we need to add a line to kick start things when a new WebSqlDB object is instantiated.
Great, so our whole web-sql-storage.js file should now look like the following.
In my next post we’ll create the main app object thats going to power our app, bind our events and handle any DOM manipulation.