public class MongoBackend extends Object implements DriveBackend
| Constructor and Description |
|---|
MongoBackend() |
| Modifier and Type | Method and Description |
|---|---|
void |
connect(String hostURL,
String username,
String password,
String database,
String table)
Creates a connection to the backend
|
void |
delete(Query queryDetails)
Deletes an object from the backend if found
|
void |
deleteAll(Query queryDetails)
Deletes all entries matched by the query
|
List<DriveObject> |
findAll(Query queryDetails)
Read all objects matching the query parameters
|
List<DriveObject> |
findAll(Query queryDetails,
Pageable pageable)
Read all objects matching the query parameters
|
DriveObject |
findOne(Query queryDetails)
Reads one object matching the query parameters
|
void |
prepareEntity(Class<?> clazz)
Prepares to use a specific entity.
|
Iterable |
rawQuery(Object query)
Deprecated.
|
void |
replace(DriveObject element,
Query query)
Replaces the first element that matches the query
|
Iterable |
sendRawQuery(org.bson.conversions.Bson query)
Send a query directly to the mongo database
|
void |
setService(DriveService service)
Sets the service the backend is used by.
|
void |
write(DriveObject driveObject,
Query query)
Writes an object to the database.
|
void |
writeReplace(DriveObject element,
Query queryDetails)
Removes one element equal to the query details and adds the element in place
|
public void connect(String hostURL, String username, String password, String database, String table)
connect in interface DriveBackendhostURL - host url used when establishing the connectionusername - the username used when establishing the connectionpassword - the password used when establishing the connectiondatabase - database used when connecting. (Some backends might have this in their url)table - default table used. Depending on the type a default table might be neededpublic void setService(DriveService service)
setService in interface DriveBackendservice - service the backend is used bypublic void write(DriveObject driveObject, Query query)
DriveBackendwrite in interface DriveBackenddriveObject - object to savequery - used to define a custom collectionpublic Iterable sendRawQuery(org.bson.conversions.Bson query)
query - the raw query used to send the message@Deprecated public Iterable rawQuery(Object query)
rawQuery in interface DriveBackendquery - backend dependant. For MongoDB see QueryBuilderpublic void prepareEntity(Class<?> clazz)
prepareEntity in interface DriveBackendclazz - the class of the entity to savepublic DriveObject findOne(Query queryDetails)
findOne in interface DriveBackendqueryDetails - the query to usepublic List<DriveObject> findAll(Query queryDetails)
findAll in interface DriveBackendqueryDetails - the query to usepublic List<DriveObject> findAll(Query queryDetails, Pageable pageable)
DriveBackendfindAll in interface DriveBackendqueryDetails - the query to usepageable - the pageable used for paginationpublic void writeReplace(DriveObject element, Query queryDetails)
writeReplace in interface DriveBackendelement - element to insertqueryDetails - used to filter for deletionpublic void replace(DriveObject element, Query query)
DriveBackendreplace in interface DriveBackendelement - element that will replace the matched elementquery - used to filter for replacingpublic void deleteAll(Query queryDetails)
deleteAll in interface DriveBackendqueryDetails - the query details used to filterpublic void delete(Query queryDetails)
delete in interface DriveBackendqueryDetails - the query details used to filterCopyright © 2020. All rights reserved.