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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ajayos/nodemongoose

v1.0.0

Published

Nodemongoose is a simple key-value store for Node.js, built on top of mongoose.

Downloads

12

Readme

NodeMongoose

NodeMongoose is a Node.js library that simplifies MongoDB database interactions using the Mongoose ODM (Object Data Modeling). It provides an intuitive class-based interface to perform common MongoDB operations with ease.

Installation

You can install NodeMongoose using npm:

npm install @ajayos/nodemongoose

Usage

  1. Import the NodeMongoose class and instantiate it with your MongoDB URL:
const NodeMongoose = require('@ajayos/nodemongoose');

const url = 'your-mongodb-url'; // Replace with your MongoDB URL
const db = new NodeMongoose(url);
  1. Utilize the available class methods to interact with the database, as demonstrated in the examples below.

Project Overview

NodeMongoose streamlines the process of connecting to MongoDB and performing operations on your data. Whether you're building a small application or a complex system, NodeMongoose provides a consistent and convenient API for managing your data in a MongoDB database.

Functions and Usage

setDB(tableName, rowName, data)

Inserts or updates a row in the specified table with the specified key and data.

Example Usage:

await db.deleteDB('users', 'ajay');

Example Usage (Delete Table):

await db.deleteDB('users');

setDATA(tableName, rowName, data: any)

Similar to setDB, but stores data without JSON stringifying it.

Example Usage:

await db.setDATA('metadata', 'version', 1.2);

getDATA(tableName, rowName)

Similar to getDB, but retrieves data without JSON parsing it.

Example Usage:

const version = await db.getDATA('metadata', 'version');
console.log(version); // 1.2

Example Usage (All Rows):

const allVersions = await db.getDATA('metadata');
console.log(allVersions); // [ { rowName: 'version', data: 1.2 }, ... ]

deleteDATA(tableName, rowName)

Similar to deleteDB, but deletes data without JSON parsing it.

Example Usage:

await db.deleteDATA('metadata', 'version');

Example Usage (Delete Table):

await db.deleteDATA('metadata');

Example

Here's a complete example of using NodeMongoose to interact with a MongoDB database:

const NodeMongoose = require('@ajayos/nodemongoose');

async function main() {

  const url = 'your-mongodb-url'; // Replace with your MongoDB URL
  const db = new NodeMongoose(url);

  // Set data using setDB
  await db.setDB('users', 'ajay', { name: 'Ajay o s', age: 20 });

  // Get data using getDB
  const ajay = await db.getDB('users', 'ajay');
  console.log('Retrieved Data:', ajay);

  // Delete a specific row using deleteDB
  await db.deleteDB('users', 'ajay');

  await db.disconnect();
}

// Run the main function
main().catch((error) => {
  console.error('An error occurred:', error);
});

Note

For functions like deleteDB and deleteDATA, if you provide only the tableName, the entire table will be deleted. To delete a specific row, provide both tableName and rowName.

License

NodeMongoose is licensed under the Apache License 2.0. See the LICENSE file for details.

Repository

You can find the repository for NodeMongoose on GitHub at https://github.com/Ajayos/nodemongoose