diff --git a/Home.md b/Home.md index f3a9d2e..73b62af 100644 --- a/Home.md +++ b/Home.md @@ -1,7 +1,26 @@ -# Getting Started -Hello, let's get started with using Feather! +# Feather +Feather is an efficient lightweight database library. + +## Dependency +First off, you need to get the dependency into your project so you can use it. + +### Maven +```xml + + me.braydon + Feather + 1.0-dev + +``` + +### Gradle (Kotlin DSL) +```kotlin +implementation("me.braydon:Feather:1.0-dev") +``` ## Connecting +Connecting to a database is very simple, all you have to do is construct the instance of the database you would like to connect to, and then invoke it's `#connect(credentials)` method. + ```java MongoDB mongo = new MongoDB(); // Create the database instance mongo.connect(new ConnectionString("mongodb://admin:p4$$w0rd@localhost:27017/feather?authSource=admin")); // Connect to the MongoDB server @@ -10,4 +29,39 @@ mongo.connect(new ConnectionString("mongodb://admin:p4$$w0rd@localhost:27017/fea mongo.close(); ``` -## Other Resources \ No newline at end of file +## Examples + +### Saving & Finding an entity +```java +public static void main(@NonNull String[] args) { + MongoDB mongo = new MongoDB(); // Create the database instance + mongo.connect(new ConnectionString("mongodb://admin:p4$$w0rd@localhost:27017/feather?authSource=admin")); // Connect to the MongoDB server + + // Create a new player repository, and add a player to it + MongoRepository repository = mongo.newRepository("players", Player.class); + repository.save(new Player(uuid, "Rainnny")); // Save our player + + // Get the player from the repository that we just saved + Player found = repository.find(uuid); + System.out.println("player = " + (found == null ? "n/a" : found)); + + // Close the database connection after our app is finished + mongo.close(); +} + +/** + * A simple player entity. + */ +@NoArgsConstructor @AllArgsConstructor @Getter @ToString +public static class Player { + /** + * The uuid of this player. + */ + @Id @Field private UUID uuid; + + /** + * The name of this player. + */ + @Field(key = "name") @Index private String username; +} +``` \ No newline at end of file