npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@titanpl/mongo

v0.0.2

Published

MongoDB client for Titan Planet Framework

Downloads

38

Readme

@titanpl/mongo

A high-performance, native MongoDB extension for the Titan Planet Framework, built with Go.

Installation

Install the extension in your TitanPl project:

npm install @titanpl/mongo

Add the extension to your Titan project's tanfig.json:

{
  "name": "your-app",
  "extensions": {
    "allowNative": [
      "@titanpl/core",
      "@titanpl/mongo"
    ]
  }
}

Usage

The extension provides a synchronous, fluent API that mirrors the official MongoDB driver while handling all heavy lifting in the native Go layer.

Basic Setup

Create a connection in a shared file (e.g., app/db.js):

import { mongo } from "@titanpl/mongo";

// Connect once at module load
// Ensure DB_URI is set in your .env
const client = mongo(t.env.DB_URI);

export const db = client.db("my_database");
export const users = db.collection("users");

CRUD Operations

import { users } from "../db";

export function getProfile(req) {
    const userId = req.query.id;
    
    // Find documents (blocks until Go returns data)
    return users.find({ _id: userId });
}

export function signup(req) {
    const newUser = req.body;
    
    // Insert document
    return users.insert(newUser);
}

API Reference

mongo(uri)

Initializes a native connection pool to the specified MongoDB URI.

client.db(name)

Returns a Database instance.

db.collection(name)

Returns a Collection instance.

collection.find(filter, options)

  • filter: MongoDB query object. Supports automatic string-to-ObjectID conversion for _id fields.
  • options: { limit: number, skip: number }

collection.insert(doc)

Inserts a document. Returns { insertedId: string }.

Performance Optimization

The extension is designed for high-concurrency environments with a dedicated Go connection pool.

Latency Characteristics

  • Initial Connection (10-15s): The very first request to a cluster (especially on Atlas) may take some time (e.g., 15s) as the native layer performs SRV DNS resolution and establishes the initial secure TLS handshake.
  • Subsequent Requests (50-80ms): Once the connection is established, subsequent calls use the active pool and typically return in 50-80ms, depending on your index performance and network distance.
  • Release Build: For production, use titan build -r. The release build of the TitanPL engine optimizes native bridge throughput, leading to even lower latencies.

Best Practices

  • Reuse Connections: Always initialize your mongo() client at the module level (outside of action functions). This ensures you use the internal Go connection pool instead of reconnecting on every request.
  • Indexing: Ensure your MongoDB collections have proper indexes for the fields you are filtering on.
  • Internal Handling: This extension uses a C-Shared bridge which minimizes serialization overhead by using direct memory pointers between JS and Go.

Development

To rebuild the native component:

npm run build:native

Requires Go 1.18+ and CGO_ENABLED=1.