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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mdb-lambdash

v1.6.0

Published

Query lambdas for MongoDB Atlas

Downloads

10

Readme

lambdash - Lamb - dash

Lamb-dash

Not production ready!

This code is highly experimental and covers mostly the happy path, there is almost no testing and no good logic for error handling.


This module uses the MongoDB Atlas and Realm APIs to create HTTP endpoints for MongoDB queries.

The module exposes an API that can be used in other tools (e.g. the MongoDB Shell) to help users quickly create a serverless backend based on MongoDB queries and aggregation.

How to use Lambdash

Install it from npm with

$ npm install mdb-lambdash

API

Create an instance of Lambdash

clusterConnectionString is not used for anything connection related. Lambdash internally uses the MongoDB Atlas API to fetch information about all the cluster in your Atlas organization and try to find the one that corresponds to the clusterConnectionString based on hostname:port.

That is the cluster that will be used by default as a data source when setting up the Realm infrastructure for your queries.

const Lambdash = require('lambdash');

const lambdash = new Lambdash({ clusterConnectionString: 'mongodb+srv://some.url?options' });

Login

await lambdash.login({username: 'ABCDEFGH', apiKey: '7b8d3018-dfb3-4ea4-8713-eb6d23438f1d'});

When you call this method, Lambdash will set up the client to talk to the Atlas Public API and login with the Realm Admin API to fetch the auth tokens.

Create a query lambda

await lambdash.createLambdaFromCommand({
  command: `db.collToUse.aggregate([{$match: {foo: {$gt: bar}}}]).lambda({name: 'queryLambdaName', paramTypes: {bar: 'Int32'}, secret: '321littleMonkeysJumpingOnTheBed', format: 'csv'})`,
  database: 'databaseToUse'
});

This will parse command into an AST and extract the right information from the lambda() method and the collection name from the command. The query or aggregation will also be parsed and the variables extracted to become query parameters.

Then, based on the information that was extracted, it will generate a Real function that will be turned into a webhook after doing all the necessary Realm plumbing (App setup and HTTP and Atlas services creation).

If secret is not specified, Lambdash will generate a random one to secure the endpoint.

format can be json (the default) or csv.

There is also another method:

await lambdash.createLambda('queryLambdaName', {
  secret: '321littleMonkeysJumpingOnTheBed',
  queryOrAggregation: '[{$match: {foo: {$gt: bar}}}]',
  paramTypes: { bar: 'Int32' },
  database: 'databaseToUse',
  collection: 'collToUse'
});

This works similar as the above, except that all the parameters are passed expicitly and the AST is only generated for queryOrAggregation to extract the variables that will become query parameters when the query lambda is generated. This method is less battle-tested than the one above.

Credits:

  • **Icon: ** Lamb by Symbolon from the Noun Project