Code Explainers

Code explainers tagged #database

go
type PostCursor struct {
	CreatedAt time.Time
	ID        int64
}

Keyset pagination with cursors in Go

pagination keyset-cursor database
Intermediate 8 steps
java
public class KeysetPaginationRepository {
 
    private final DataSource dataSource;
 

How keyset pagination works in Java

pagination sql jdbc
Intermediate 8 steps
rust
use axum::{
    extract::{FromRef, FromRequestParts},
    http::{request::Parts, StatusCode},
    response::{IntoResponse, Response},

A custom API-key extractor in Axum

authentication extractors trait-implementation
Advanced 8 steps
go
func (r *EventRepository) BatchInsert(ctx context.Context, events []Event) error {
	if len(events) == 0 {
		return nil
	}

Batch inserting rows in a Go transaction

transactions batching database
Intermediate 7 steps
java
@DataJpaTest
@Testcontainers
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class OrderRepositoryIT {

Testing a JPA repository against real Postgres in Spring

integration-testing testcontainers jpa
Intermediate 8 steps
php
<?php
 
namespace App\Http\Controllers;
 

Streaming a large CSV export in Laravel

streaming csv-export memory-efficiency
Intermediate 9 steps
php
public function importUsers(array $users): int
{
    $inserted = 0;
 

Bulk-inserting users with batched PDO upserts

batching bulk-insert prepared-statements
Intermediate 6 steps
go
package store
 
import (
	"database/sql"

Wrapping and inspecting errors in Go

error-handling error-wrapping sentinel-errors
Intermediate 8 steps