class Reminder < ApplicationRecord
belongs_to :user
validates :time_zone, inclusion: { in: ActiveSupport::TimeZone::MAPPING.values }
validates :local_time, presence: true
package store
import (
"context"
"github.com/jackc/pgx/v5"
class BatchLoader {
constructor(batchFn, { cacheKeyFn = (k) => k } = {}) {
this.batchFn = batchFn;
this.cacheKeyFn = cacheKeyFn;
this.cache = new Map();
this.queue = [];
class InventoryLevel < ApplicationRecord
belongs_to :warehouse
UPSERT_COLUMNS = %w[warehouse_id sku on_hand reserved updated_at].freeze
def self.upsert_counts(rows)
CREATE TABLE password_reset_tokens (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token_hash TEXT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ,
import { QueryResultRow } from 'pg';
import { pool, Queryable } from './db';
export abstract class BaseRepository<T extends QueryResultRow> {
protected abstract readonly table: string;
class Order < ApplicationRecord
class InvalidTransition < StandardError; end
enum status: { pending: 0, paid: 1, shipped: 2, cancelled: 3 }
has_many :order_transitions, -> { order(:created_at) }, dependent: :destroy
package health
import (
"context"
"sync"
"time"
class User < ApplicationRecord
normalizes :phone, with: ->(value) { PhoneNormalizer.call(value) }, apply_to_nil: false
validates :phone,
presence: true,
uniqueness: { case_sensitive: false },
const fs = require('fs');
const readline = require('readline');
async function* streamCsvRows(filePath) {
const stream = fs.createReadStream(filePath, { encoding: 'utf8' });
const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
package migrate
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"