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

swapp.js

v1.0.2

Published

An universal database adapter that simplifies DB setups and lets you use the same query language across both SQL and NoSQL databases.

Readme

Swapp.js - The Universal DB Adapter for Effortless CRUD

Skip the setup. Write once, query everywhere.

Forget about the hectic boilerplate copy-pasting for database setups. Swapp lets you set up a database in a single statement, so that you can now spend your time actually building your app, not on configuring the database itself.

Currently, Swapp.js supports MongoDB and Supabase. More databases are under development and support will increase soon.

Swapp.js NPM Page

Installation

Swapp.js can be installed simply by using the Node Package Manager (npm):

npm install swapp.js --legacy-peer-deps

or

yarn add swapp.js

Note: By default, npm v7+ installs peerDependencies by default. To prevent this, use --legacy-peer-deps as above. Otherwise, it would install all peerDependencies automatically, like mongodb, @supabase/supabase-js and all the supported databases' packages.

Configuring a Database

MongoDB

const db = new Swapp({
  provider: "mongodb",
  config: {
    connectionString: "<mongodb-connection-string>",
    dbName: "<mongodb-database-name>"
  }
});
await db.initialize();

Supabase

const db = new Swapp({
  provider: "supabase",
  config: {
    supabaseKey: "<Supabase-Key>",
    supabaseUrl: "<Supabase-URL>"
  }
});
await db.initialize();

CRUD Operations

This is where the fun factor of Swapp.js starts. The syntax for these operations remain the same, no matter which database (SQL/NoSQL) you choose.

Create/Save (C)

await db.save("pokemon", {name: "Greninja", level: 45});
// db.save(collection: string, data: object);

Read/Get (R)

await db.get("pokemon", 'WHERE name = "Greninja"');
// db.get(collection: string, query?: string);
// If no query is passed, all contents of the database will be listed.

Update (U)

await db.update("pokemon", 'WHERE name = "Greninja"', {name: "Lucario", level: 45});
// db.update(collection: string, query: string, updateData: object);

Delete (D)

await db.delete("pokemon", 'WHERE level = 45');
// db.delete(collection: string, query: string);

The Query Language

In the above examples, the query used is a SQL-like query language, that is internally translated and adapted into the database chosen by the user. This query language is not as huge as SQL, but supports the extreme basics required for most operations: WHERE, ORDER BY and AND.

WHERE

This clause checks which fields satisfy the condition described in the clause. Example, 'WHERE name = "Greninja"' will check for entries in the DB with the field name having the value "Greninja".

Example usage: WHERE name = "Greninja" AND level = 45

ORDER BY

This clause returns the result of the search in the database and arranges it in the specified order (either ascending (ASC) or descending (DESC)).

Example usage: ORDER BY level // uses ascending order by default Example usage: ORDER BY level ASC // ascending order Example usage: ORDER BY level DESC // descending order

Support Me

Maintaining and improving Swapp.js takes time and effort. If you find it helpful and want to show some love, consider buying me a coffee! Your support helps me keep the project alive and improve it further.

License

This project is licensed under the MIT License.