DEV Community

Adam Miedema
Adam Miedema

Posted on • Originally published at Medium on

4 2

How to create a to-do list app with Alpas

I created a quick to-do list app to better familiarize myself with some of Alpas’s key features and I want to share my example with you! 🚀

Here is a quick-start tutorial that will help guide you though creating your very own to-do list app as well as giving you a tour through a few of Alpas’s features, such as:

  • How to get Alpas setup and running on your local device
  • How to connect with a MySQL database
  • How to create database tables in Alpas and migrate them
  • How to create, retrieve, update, and delete data in your MySQL database
  • How to create a database entity object
  • How to create a controller
  • How to add routes
  • How to interact with the MySQL database using Ozone
  • How to protect your app against the cross site request forgery attacks
  • How to connect an interactive front-end with the powerful Alpas back-end
  • How to create a fun, yet useful to-do list! ✅

Here is a snippet from the guide on how you can store a new to-do task to your database (just to give you a taste 🍦 🙂).

// Let's create a function to store a new todo item that have been added via a form.

    fun store(call: HttpCall) {

        // Before we write the new todo task to the database, 
        // let's first validate to
        // make sure there is data with at least 2 characters. 
        // If validation fails,
        // a message will be sent back to the user with the failure 
        // reasons.

        call.applyRules("newTask") {
            required()
            min(2)
        }.validate()

        // If validation has passed, then create a new todo item in  
        // the database

        Tasks.create() {
            // Get the name of the task that was passed
            val taskName = call.stringParam("newTask")
            it.name to taskname
        }

        // If a new todo task has successfully been created and   
        // saved to the database,
        // let's send a success message back to the user to let them  
        // know.

        flash("success", "Successfully added to-do")
        call.redirect().back()
    }

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay