Skip to content

Latest commit

 

History

History
97 lines (70 loc) · 2.21 KB

README.md

File metadata and controls

97 lines (70 loc) · 2.21 KB

🗄️ MongoDB Framework

A flexible MongoDB fast connection framework built on top of Morphia.

JDK License

✨ Key Features

  • 🏭 Factory-Based Configuration
    • Simple connection setup via MongoDBConnectionConfigFactory

📚 Quick Start

Installation

dependencies {
    implementation("net.legacy.library:mongodb:1.0-SNAPSHOT")
}

Basic Usage

1️⃣ Create Connection

MongoDBConnectionConfig config = MongoDBConnectionConfigFactory.create(
    "mydb",
    "mongodb://localhost:27017/",
    UuidRepresentation.STANDARD
);

Datastore datastore = config.getDatastore();

2️⃣ Define Entity

@Entity("users")
public class User {
    @Id
    private ObjectId id;
    private String name;
    private int age;
    
    // Getters and setters
}

3️⃣ Perform Operations

// Save entity
User user = new User("John", 25);
datastore.save(user);

// Query entity
List<User> users = datastore.find(User.class)
    .filter(Filters.eq("name", "John"))
    .iterator()
    .toList();

🔧 Core Components

Connection Configuration

  • MongoDBConnectionConfig: Central configuration class
  • Custom client settings
  • Connection lifecycle management

Factory System

  • MongoDBConnectionConfigFactory: Factory for creating configurations
  • Support for custom MongoDB settings
  • UUID representation handling

🎯 Advanced Features

Custom Client Settings

MongoClientSettings settings = MongoClientSettings.builder()
    .applyConnectionString(new ConnectionString("mongodb://localhost:27017"))
    .uuidRepresentation(UuidRepresentation.STANDARD)
    .build();

MongoDBConnectionConfig config = MongoDBConnectionConfigFactory.create(settings);

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Made with ❤️ by LegacyLands Team