MemoriaDB is a lightweight, in-memory database library for Node.js, designed for simplicity and ease of use. It provides basic CRUD operations, schema validation, and unique constraints, making it ideal for prototyping, testing, or small-scale applications.
- In-Memory Storage: Data is stored in memory, making it fast and lightweight.
- Schema Validation: Define schemas with fields, required fields, and unique constraints.
- CRUD Operations: Create, Read, Update, and Delete records with ease.
- TypeScript Support: Built with TypeScript for type safety and better developer experience.
- Simple API: Easy-to-use API for managing collections and records.
You can install memoriadb
via npm:
npm install memoriadb
Or using yarn:
yarn add memoriadb
import { Schema } from "memoriadb";
const User = Schema({
fields: {
firstName: String,
lastName: String,
email: String,
password: String,
},
required: ["email", "password"],
unique: ["email"],
collection: "User",
});
You can create a new record using the schema:
const newUser = new User({
firstName: "John",
lastName: "Doe",
email: "john.doe@example.com",
password: "securepassword123",
});
Retrieve records using the static methods provided by the schema:
// Find all users
const allUsers = await User.find();
// Find a user by ID
const userById = await User.findById("97264891993");
// Find a user by a specific field
const userByEmail = await User.findOne({
field: "email",
value: "john.doe@example.com",
});
Update a record by its ID:
const updatedUser = await User.updateById("97264891993", {
firstName: "Jane",
});
Delete a record by its ID:
await User.deleteById("123");
Contributions are welcome! If you'd like to contribute to MemoriaDB, please follow these steps:
-
Fork the repository.
-
Create a new branch for your feature or bugfix.
-
Commit your changes.
-
Submit a pull request.
MemoriaDB is open-source software licensed under the MIT License.