Sign in

    moondark_postgresql

    PostgreSQL backends for the moondark framework

    moondark
    postgresql
    database
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    1 hour ago
    Downloads
    2

    #moondark_postgresql

    PostgreSQL integration module for MoonDark, providing a database driver and PostgreSQL-backed sessions, task queues, credentials, and file catalogs.

    #Quick Start

    ///|
    async test {
    @async.with_task_group(group => {
    let (db, executor) = @postgresql_database.open_db(
    "postgres://user:pass@localhost:5432/app?sslmode=disable",
    )
    group.spawn_bg(no_wait=true, () => executor.run())
    db.ready()
    defer db.close()
    let row = db.query_one("SELECT $1::int4 + 1 AS n", params=[41])
    assert_eq((row.get_name("n") : Int32), 42)
    })
    }

    #Packages

    PackageCore InterfacePublic API
    KKKIIO/moondark_postgresql/databasedatabase/driveropen_db, Driver
    KKKIIO/moondark_postgresql/sessionssessions.SessionStorePostgresSessionStore
    KKKIIO/moondark_postgresql/taskstasks.DBTaskBackend, tasks.TaskStorePostgresTaskBackend
    KKKIIO/moondark_postgresql/filesfiles.Catalog, files.FileStorePostgresCatalog, new_file_store
    KKKIIO/moondark_postgresql/authauth.CredentialStorePostgresCredentialStore

    #Sessions

    Apply sessions/schema.sql to create the sessions table, then wire PostgresSessionStore into the session middleware:

    CREATE TABLE IF NOT EXISTS sessions ( session_key VARCHAR(64) PRIMARY KEY, session_data TEXT NOT NULL, expires_at BIGINT NOT NULL );

    let store = @postgresql_sessions.PostgresSessionStore(db)
    app.add_middleware(@sessions.middleware(store))

    #Files

    Apply files/schema.sql, then construct a persistent file store. PostgreSQL holds the catalog; immutable blobs live under root:

    let store = @postgresql_files.new_file_store(
    db,
    root="./uploads",
    key="app-secret",
    )
    store.put(key="documents/paper.pdf", pdf, content_type="application/pdf")

    Mount store.routes() on your app for presigned uploads and downloads. Store instances using the same catalog must share the blob directory. See the files quick start for complete setup.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io