Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
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.
You can install Sreya via npm:
npm install sreya
import * as sreya from 'sreya';
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');
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');
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');
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);
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);
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' });
You can delete a collection and its associated JSON file using the destroy
function.
await sreya.collection.destroy('mycollection');
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.
This project is licensed under the MIT License - see the LICENSE file for details.
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!
FAQs
Sreya is a versatile in-memory database for Node.js applications.
We found that sreya demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.