Class Mongo

java.lang.Object
com.github.pinont.singularitylib.api.storage.Mongo
All Implemented Interfaces:
AutoCloseable

public class Mongo extends Object implements AutoCloseable
Thin MongoDB client for the Singularity framework (Phase 2).

Configuration section (e.g. from config.yml):

database:
  host: localhost
  port: 27017
  databaseName: minecraft
  username: ""   # optional
  password: ""   # optional

Sync operations only; pair with the async Database facade if you need off-thread execution patterns.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Mongo(org.bukkit.plugin.Plugin plugin, org.bukkit.configuration.ConfigurationSection cfg)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    long
    count(String collection, org.bson.Document filter)
    Counts matching documents.
    void
    delete(String collection, org.bson.Document filter)
    Deletes all documents matching the filter.
    org.bson.Document
    findFirst(String collection, org.bson.Document filter)
    Finds the first document matching the filter.
    void
    insert(String collection, org.bson.Document doc)
    Inserts a document.
    void
    upsert(String collection, org.bson.Document filter, org.bson.Document update)
    Upserts: $set the update fields on the first match, inserting if absent.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Mongo

      public Mongo(org.bukkit.plugin.Plugin plugin, org.bukkit.configuration.ConfigurationSection cfg)
  • Method Details

    • findFirst

      public org.bson.Document findFirst(String collection, org.bson.Document filter)
      Finds the first document matching the filter.
    • insert

      public void insert(String collection, org.bson.Document doc)
      Inserts a document.
    • upsert

      public void upsert(String collection, org.bson.Document filter, org.bson.Document update)
      Upserts: $set the update fields on the first match, inserting if absent.
    • delete

      public void delete(String collection, org.bson.Document filter)
      Deletes all documents matching the filter.
    • count

      public long count(String collection, org.bson.Document filter)
      Counts matching documents.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable