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

sreya

v1.3.1

Published

Sreya is a versatile in-memory database for Node.js applications.

Downloads

10

Readme

Sreya

Sreya is a lightweight npm package for storing and managing data using JSON files as collections. It provides simple and efficient CRUD (Create, Read, Update, Delete) operations for working with collections stored locally on your file system.

Installation

You can install Sreya via npm:

npm install sreya

Usage

Importing the Package

import * as sreya from 'sreya';

Connecting to a Database

Before using any CRUD operations, you need to connect to a database. This operation creates a directory for your database if it doesn't exist and retrieves a list of existing collections.

await sreya.connect('mydatabase');

Creating a Collection

You can create a new collection using the create function. If the collection already exists, this function will return a message indicating that the collection already exists.

sreya.collection.create('mycollection');

Finding Data in a Collection

You can retrieve the data stored in a collection using the find function. This function returns an array of objects representing the data in the collection.

const data = sreya.collection.find('mycollection');

Inserting Data into a Collection

To add new data to a collection, use the insert function. This function automatically generates a unique _id for the new data before insertion.

const newData = { name: 'John', age: 30 };
await sreya.collection.insert('mycollection', newData);

Updating Data in a Collection

You can update existing data in a collection using the update function. Provide a key-value pair to match the item to update and the new data.

const newData = { name: 'Jane', age: 25 };
await sreya.collection.update('mycollection', { key: 'name', value: 'John' }, newData);

Removing Data from a Collection

To remove an item from a collection based on a key-value pair, use the remove function.

await sreya.collection.remove('mycollection', { key: 'name', value: 'John' });

Destroying a Collection

You can delete a collection and its associated JSON file using the destroy function.

await sreya.collection.destroy('mycollection');

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Special thanks to all contributors who have helped to improve and maintain this project.


This documentation provides an overview of the main functionalities of Sreya. For more detailed usage instructions and examples, refer to the API documentation or explore the source code.

If you have any questions or need further assistance, don't hesitate to reach out!