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

vantedb

v3.5.4

Published

VanteDB is a simple, lightweight database library for Node.js.

Downloads

58

Readme


VanteDB is a lightweight Node.js database library that simplifies basic CRUD (Create, Read, Update, Delete) operations on JSON files. It's designed to be easy to use and suitable for small to medium-sized projects where a full-fledged database system might be overkill

Features

  • Simple Setup: Get started quickly with minimal configuration.
  • JSON Storage: Store data in JSON files for easy readability and management.
  • Asynchronous Operations: Perform database operations asynchronously using Promises.
  • Filter and Update: Easily filter and update records in your collections.

Usage

const VanteDatabase = require('vantedb');

// Define a schema for a collection
const userSchema = {
    username: { type: String, default: 'Kaan Karahanlı' },
    age: Number,
    email: { type: String, default: "[email protected]" },
    isAdmin: Boolean,
    interests: Array,
    daily: Number,
    total: Number,
};

// Create a model for the "users" collection
const UserModel = VanteDatabase.model({
    Collection: 'Users',
    Folder: './Global/Database/',
    Cluster: true,
    Type: [],
}, userSchema);

// Create a model for the "settings" collection (this one is for the key chain dbs)
const SettingsModel = VanteDatabase.model({
    Collection: 'Settings',
    Folder: './Global/Database/',
    Cluster: false,
    Type: {},
}, userSchema);

// Example data
const userData = {
  username: 'Kaan Karahanlı',
  age: 19,
  email: '[email protected]',
  isAdmin: false,
  interests: ['coding', 'reading', 'ertus-mom'],
};

// CRUD operations
(async () => {
  try {
    // Create a User
    await UserModel.create(userData, { Cluster: "VANTE" });

    // FIND USERS
    
    // Find multiple users with conditions
    const users = await UserModel.find({
        $and: [
            { age: { $gte: 20, $lte: 30 } },
            { isAdmin: true }
        ]
    }, { Cluster: 'VANTE' });

    // Find a single user with conditions
    const user = await UserModel.findOne({
        $and: [
            { age: { $gte: 20, $lte: 30 } },
            { isAdmin: true },
        ]
    }, { Cluster: 'VANTE' });


    // UPDATE USER

    // Update or create a user with upsert true
    await UserModel.updateOne({ username: "kaanxsrd" }, { $inc: { daily: 1, total: 2 }}, { Cluster: 'VANTE', upsert: true });

    // Update multiple users
    await UserModel.updateMany({ age: 0 }, { $set: { age: 19 } }, { Cluster: 'VANTE' });

    // DELETE USER

    // Delete a single user
    await UserModel.deleteOne({ username: "vantesex" }, { Cluster: 'VANTE' });

    // Delete multiple users
    await UserModel.deleteMany({ age: 19 }, { Cluster: 'VANTE' });


    // Old key data version 

    // creata a new data 
    await settingsModel.create({}, { Cluster: 'VANTE' }); // not required 
    
    // Set a value in the settings
    await SettingsModel.set("vante", "19");

    // Get a value from the settings
    await SettingsModel.get("vante");

    // Get all settings
    await SettingsModel.all();

    // Push a value from an array in settings
    await SettingsModel.push("interest", "sa");

    // Pull a value from an array in settings
    await SettingsModel.pull("interest", "sa");

    // Check if a setting exists
    await SettingsModel.has("vante");

    // Add a value in settings
    await SettingsModel.add("age", 35);

    // Take a value from settings
    await SettingsModel.take("age", 16);

    // Delete a value from settings
    await SettingsModel.delete("age");

  } catch (error) {
    console.error('Error performing CRUD operations:', error.message);
  }
})();

Contributing

Contributions are welcome! If you have any bug fixes, improvements, or new features to propose, please open an issue or submit a pull request.

License

VanteDB is licensed under the GPL-3.0 License. See the LICENSE file for details.