MongoDAO Base

With an object extending MongoDAO class all functions on a specific MongoCollection can be easily used.

Base Functions like

  • drop
  • count
  • createIndex

are implemented.

Search Functions and CRUD Functions are available.

##

Additional Features

Synchronous Result

All functions support synchronous result handling.

Use pacckage import

import dev.mongocamp.driver.mongodb._

and append

  • .result() for Single Result object
  • .resultList() for List result object

or use implicit conversion:

def restaurantsSize: Long = RestaurantDAO.count()

Raw Support

Sometimes we need Raw Support (DAO maps to Document). This is automatically included in the MongoDAO class. Simply call Raw on your DAO Object.

sourceval pipeline = List(filterStage, groupStage, sortStage)

val aggregated = PersonDAO.Raw.findAggregated(pipeline).resultList()

Base Functions

Drop

Drop Collection.

def drop(): Observable[Void]

Count

Count of collection with optional filter.

def count(filter: Bson = Document()): Observable[Long]

Indexes


def createIndex(key: Bson, options: IndexOptions = IndexOptions()): SingleObservable[String] // Simple Index creation def createIndexForField(field: String, sortAscending: Boolean = true): SingleObservable[String] def dropIndex(keys: Bson): SingleObservable[Void] // Simple Index delete def dropIndexForName(name: String): SingleObservable[Void]