Nixabase is a lightweight, flexible, and efficient database management system for Node.js applications. It provides a simple interface for storing and retrieving data in both JSON and TXT formats, with additional features like memory caching and image compression.
- Dual Format Support: Store data in either JSON or TXT format.
- Memory Caching: Improve read performance with optional in-memory caching.
- File Upload: Built-in support for file uploads, including image compression.
- Asynchronous Operations: All database operations are asynchronous for better performance.
- Error Handling: Robust error handling for database operations.
- Flexible Configuration: Customize database behavior through various options.
Install Nixabase using npm:
npm install nixabase
const Nixabase = require('nixabase');
const db = new Nixabase('path/to/database.json', {
format: 'json', // or 'txt'
performance: {
memory: {
enabled: true,
maxItemCount: 1000
},
imageCompression: {
enabled: true,
level: 6,
quality: 80,
resize: { width: 800, height: 600 }
}
}
});
// Save data
await db.save('user1', { name: 'John Doe', age: 30 });
// Retrieve data
const user = await db.get('user1');
console.log(user); // { name: 'John Doe', age: 30 }
// Update data
await db.update('user1', { name: 'John Doe', age: 31 });
// Delete data
await db.delete('user1');
// Upload a file
await db.uploadFile('path/to/image.jpg', 'profile_pic');
// Retrieve a file
const fileBuffer = await db.getFile('profile_pic');
Creates a new Nixabase instance.
-
filePath
: Path to the database file. -
options
: Configuration options (optional).-
format
: 'json' or 'txt' (default: 'json'). -
performance
: Performance-related options.
-
Saves a key-value pair to the database.
Retrieves a value from the database by its key.
Updates an existing key-value pair in the database.
Deletes a key-value pair from the database.
Uploads a file to the database with optional image compression.
Retrieves a file from the database.
Nixabase offers performance optimization through memory caching and image compression. These features can be enabled and configured in the constructor options.
Nixabase uses async/await and throws errors when operations fail. It's recommended to use try-catch blocks when working with Nixabase methods.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Nixabase is created and maintained by Nixaut.