A lightweight document-oriented database implemented in C++ that mimics basic MongoDB functionality. This project provides CRUD operations for document management with data persistence using a JSON-like storage format.
-
Document Management
- Create and store documents with custom key-value pairs
- Retrieve documents by ID
- Update existing documents
- Delete documents from the database
-
Data Storage
- Efficient linked list implementation for in-memory storage
- JSON-based file persistence
- Automatic data loading and saving
-
User Interface
- Interactive command-line interface
- Simple and intuitive menu system
- Clear feedback for all operations
database/
├── Makefile
├── README.md
├── SimpleDB
├── data/
│ └── database.json
├── include/
│ └── DocumentDB.h
└── src/
├── main.cpp
└── main.o
- C++ compiler (GCC 4.9+ recommended)
- Make build system
- Basic understanding of C++ programming
- Basic Understanding of MongoDB.
- Clone the repository
https://github.com/GauravKesh/database.git
cd database- Build the project
makeRun the program:
./SimpleDB-
Insert Document
Choose option: 1 Enter Document ID: doc1 Enter fields (key:value): title:Hello content:World -
Find Document
Choose option: 2 Enter Document ID: doc1 -
Update Document
Choose option: 3 Enter Document ID: doc1 Enter new fields: title:Updated -
Remove Document
Choose option: 4 Enter Document ID: doc1 -
Display All Documents
Choose option: 5 -
Save to File
Choose option: 6
{
"id": "doc1",
"fields": {
"title": "Hello",
"content": "World"
}
}- Clean the project:
make clean- Build the project:
make- Run tests (if implemented):
make test- Fork the repository
- Create a feature branch (
git checkout -b feature/<feature name>) - Commit your changes (
git commit -m 'Add some <feature name>') - Push to the branch (
git push origin feature/<feature name>) - Open a Pull Request
The program includes robust error handling for common scenarios:
- Invalid document IDs
- Duplicate documents
- File I/O errors
- Malformed input
- Uses linked list for efficient document insertion
- Minimal memory footprint
- Quick lookup by document ID
- Efficient file I/O operations
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by MongoDB's document-oriented architecture
- Built using modern C++ features
- Implements best practices for data persistence
For support, please open an issue in the repository.