Skip to content

alpheratzteam/alpheratz-database

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AlpheratzDatabase

  • An experimental project of database

HOW TO USE? EXAMPLES.

CONNECT TO DATABASE

DatabaseDriver.INSTANCE.connect(new DatabaseClient(new DatabaseData("127.0.0.1", 2139, new DatabaseUser("root", "none"))), new ConnectCallback() {
            @Override
            public void success(DatabaseClient databaseClient) {
                System.out.println("Connected!");
            }

            @Override
            public void error(Throwable cause) {
                System.err.println("Exception thrown!");
            }
        });

INSERT DOCUMENT

final Collection collection = database.getCollection("test");
collection.insert(Document.parse("{\"nickname\":\"abc123\"}"));

UPDATE DOCUMENT

final Collection collection = database.getCollection("test");
collection.update(new KeyData("nickname", "abc123"), Document.parse("{\"nickname\":\"cba321\"}"));

READ ALL DOCUMENTS

         final long startTime = System.currentTimeMillis();
         collection.findAsync().setFutureListener((documents) -> {
                    DatabaseDriver.INSTANCE.getLogger().info("Found " + documents.size() + " documents in " + (System.currentTimeMillis() - startTime) + " ms.");
		  });

READ DOCUMENT

 collection.findAsync(new KeyData("nickname", "cba321")).setFutureListener((document) -> {
                    System.out.println("found: " + (Objects.nonNull(document) ? document.toString() : "null"));
                });

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages