quantadb
v1.1.1
Published
Atmosoft quantadb a simple and very easliy to use database that relly change the new era
Downloads
9
Readme
Here’s a comprehensive README.md
for quantadb
, which includes setup instructions, usage examples, and detailed information about the database.
# quantadb
**quantadb** is a simple and unique file-based database for Node.js that supports CRUD operations with sequential integer IDs. It's designed to be easy to use and integrate into your projects, offering a lightweight solution for data storage and management.
## Features
- **Sequential Integer IDs**: Automatically generates and manages sequential integer IDs starting from 1.
- **File-Based Storage**: Stores data in custom `.xdb` files, making it easy to manage and backup.
- **CRUD Operations**: Supports Create, Read, Update, and Delete operations.
- **Lightweight and Simple**: No complex setup required; works directly with file-based storage.
## Installation
1. **Install the Package Locally**
To install `quantadb` locally in your Node.js project, use the following command:
```bash
npm install quantadb
install for Development
npm i quantadb
Usage
Basic Setup
Create a new instance of
quantadb
by specifying the directory where the database files will be stored.const quantadb = require('quantadb'); const db = new quantadb('./db');
Create a Document
Create a new document in a specified collection.
async function createUser() { const user = await db.create('users', { name: 'Alice', age: 25 }); console.log('Created User:', user); }
Read Documents
Read documents from a collection with optional query parameters.
async function readUsers() { const users = await db.read('users'); console.log('Users:', users); }
Update a Document
Update an existing document by its ID.
async function updateUser(id, updates) { const updatedUser = await db.update('users', id, updates); console.log('Updated User:', updatedUser); }
Delete a Document
Delete a document by its ID.
async function deleteUser(id) { await db.delete('users', id); console.log('Deleted User with ID:', id); }
Example
Here's a complete example that demonstrates creating, reading, updating, and deleting documents:
example.js
:
const quantadb = require('quantadb');
(async () => {
const db = new quantadb('./db');
// Create users
const user1 = await db.create('users', { name: 'Alice', age: 25 });
const user2 = await db.create('users', { name: 'Bob', age: 30 });
// Read users
console.log(await db.read('users'));
// Update a user
console.log(await db.update('users', user1.id, { age: 26 }));
// Delete a user
await db.delete('users', user2.id);
// Read users again
console.log(await db.read('users'));
})();
Project Structure
The quantadb
project is structured as follows:
quantadb/
│
├── src/
│ ├── FileDatabase.js # Core file-based database implementation
│
├── test/
│ ├── server.js # Express server for testing
│ ├── public/
│ │ ├── index.html # HTML file for the front-end
│ │ ├── style.css # CSS file for styling
│ │ ├── script.js # JavaScript file for front-end logic
│
├── package.json # NPM package configuration
├── README.md # Project documentation
Contributing
If you'd like to contribute to quantadb, please fork the repository and submit a pull request. Ensure that your code adheres to the coding style and includes appropriate tests.
License
quantadb is licensed under the MIT License.
This `README.md` provides an overview of `quantadb`, including installation instructions, usage examples, and details about the project structure. Adjust the email and contact details as necessary.