public record User(Long id, String email, String displayName, boolean active) {
public static User of(String email, String displayName) {
return new User(null, email, displayName, true);
}
import { Knex } from 'knex';
export interface RawDailyRow {
day: string;
order_count: string;
gross_cents: string;
use sqlx::PgPool;
#[derive(sqlx::FromRow)]
struct User {
id: i32,
name: String,
class OverdueInvoicesQuery
def initialize(relation: Invoice.all, as_of: Time.current)
@relation = relation
@as_of = as_of
end
-- Basic EXPLAIN
EXPLAIN
SELECT * FROM users WHERE email = 'alice@example.com';
-- EXPLAIN with cost and row estimates
-- Output shows: Seq Scan on users (cost=0.00..15.50 rows=1 width=100)
package store
import (
"context"
sq "github.com/Masterminds/squirrel"
CREATE TABLE subscriptions (
id BIGGENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_id BIGINT NOT NULL,
plan_code TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
current_period_end TIMESTAMPTZ NOT NULL,
package store
import (
"context"
"time"
class ReportsController < ApplicationController
def monthly_sales
year = params.fetch(:year, Date.current.year).to_i
rows = Order.monthly_sales(year: year)
@report = MonthlySalesReport.new(rows, year: year)
module KeysetPaginatable
extend ActiveSupport::Concern
class_methods do
def keyset_page(cursor: nil, limit: 20, direction: :desc)
limit = limit.to_i.clamp(1, 100)
package feed
import (
"encoding/base64"
"encoding/json"
"time"
package store
import (
"context"
"database/sql"
)