⚠️ Development & Testing Only ⚠️
VeloceDB is a high-performance, secure, and robust local database designed specifically for development and testing environments. It is not recommended for production use, especially in mid-to-large scale applications, as it prioritizes development convenience over production-grade performance and scalability.
# Using npm
npm install velocedb
# Using yarn
yarn add velocedb
# Using pnpm
pnpm add velocedb
import { Veloce } from "velocedb";
// Initialize database with base data
const db = new Veloce("database.json", {
users: [],
settings: {},
});
// Basic operations
db.data.users = [
{ id: 1, name: "John" },
{ id: 2, name: "Jane" },
];
// Data is automatically saved
console.log(db.data.users[0].name); // "John"
import { Veloce } from "velocedb";
// Initialize with base data structure
const db = new Veloce("database.json", {
users: [],
settings: {},
});
// Create
db.data.users = [{ id: 1, name: "John" }];
// Read
const user = db.data.users[0];
// Update
db.data.users[0].name = "Johnny";
// Delete
delete db.data.users[0];
import { Veloce } from "velocedb";
// Initialize with base data structure
const db = new Veloce("database.json", {
config: {},
tasks: [],
mixed: {},
});
// Nested objects
db.data.config = {
settings: {
theme: "dark",
notifications: true,
},
};
// Arrays
db.data.tasks = [
{ id: 1, title: "Task 1", completed: false },
{ id: 2, title: "Task 2", completed: true },
];
// Mixed data types
db.data.mixed = {
string: "text",
number: 42,
boolean: true,
array: [1, 2, 3],
object: { key: "value" },
};
Proxy Mode provides advanced features like auto-save and update tracking. It's ideal for development and testing.
import { Veloce } from "velocedb";
const db = new Veloce("database.json", { value: "" });
// Auto-save enabled by default
db.data.value = "Hello World!";
No Proxy Mode is optimized for performance and direct data manipulation. It requires manual saving.
import { Veloce } from "velocedb";
const db = new Veloce("database.json", { value: "" }, { noProxy: true });
db.data = { value: "Hello World!" };
db.save(); // Manual save required
interface VeloceConfig {
// File indentation (default: 2)
indentation?: number;
// Auto-save enabled (default: true)
autoSave?: boolean;
// No-proxy mode (default: false)
noProxy?: boolean;
// Auto-save delay in milliseconds (default: 750)
autoSaveDelayMs?: number;
// Save retry timeout in milliseconds (default: 100)
saveRetryTimeoutMs?: number;
// Update callback function
onUpdate?: (method: string, result: unknown) => void;
// Maximum auto-save timeouts (default: 10)
maxAutoSaveTimeouts?: number;
// File system options (default: { encoding: "utf-8" })
fileOptions?: fs.WriteFileOptions;
// Use synchronous operations (default: false)
useSync?: boolean;
}
You canmplement functionalities like reload on file change::
import { Veloce } from "velocedb";
const db = new Veloce("database.json", {});
// Manual reload
db.reload();
// Async reload
await db.reloadAsync();
import { Veloce } from "velocedb";
const db = new Veloce("database.json", {});
// Save manually
db.save();
// Async save
await db.saveAsync();
// Delete database file
db.delete();
// Async delete
await db.deleteAsync();
import { Veloce } from "velocedb";
const db = new Veloce(
"database.json",
{},
{
onUpdate: (method, result) => {
console.log(`Operation: ${method}`);
console.log(`Result: ${result}`);
},
}
);
Development Only: Use VeloceDB exclusively for development and testing environments.
Data Structure Planning:
// Define clear data structures
interface User {
id: number;
name: string;
email: string;
}
interface Database {
users: User[];
settings: {
theme: string;
notifications: boolean;
};
}
const db = new Veloce<Database>("database.json");
Performance Optimization:
autoSaveDelayMs
for frequent updatesError Handling:
try {
db.data.value = "test";
} catch (error) {
console.error("Database operation failed:", error);
}
Production Use: Avoid using VeloceDB in production environments.
Large Datasets: Performance may degrade with very large datasets.
Concurrent Access: Not designed for concurrent access from multiple processes.
Memory Usage: Keep an eye on memory usage with large datasets.
Data Not Saving:
autoSave
is enabledPerformance Issues:
autoSaveDelayMs
File Corruption:
reload()
to refresh dataContributions are welcome! Please read our Contributing Guidelines for details.
VeloceDB is licensed under the MIT License.
For support, please: