Performing CRUD Operations
Master how to Create, Read, Update, and Delete data in your relational databases from Clojure.
What is CRUD?
When you build applications, you'll constantly interact with databases. The fundamental operations for managing data are often summarized by the acronym CRUD.
- Create: Adding new data.
- Read: Retrieving existing data.
- Update: Modifying existing data.
- Delete: Removing data.
In this lesson, we'll master how to perform these essential operations using Clojure's next.jdbc library.
Database Connection Setup
Before we perform CRUD operations, we need a database connection. We'll use next.jdbc with an in-memory SQLite database for our examples.
Remember from the previous lesson, we define a database specification (db-spec) and obtain a data source (ds) or a direct connection.
We'll create a simple users table for our examples.