public interface Repository
| Modifier and Type | Method and Description |
|---|---|
String |
add(JSONObject jsonObject)
Adds the specified json object.
|
Transaction |
beginTransaction()
Begins a transaction against the repository.
|
long |
count()
Gets the count of all json objects.
|
long |
count(Query query)
Gets the count of json objects by the specified query.
|
Map<String,JSONObject> |
get(Iterable<String> ids)
Gets json objects by the specified ids.
|
JSONObject |
get(Query query)
Gets json objects by the specified query.
|
JSONObject |
get(String id)
Gets a json object by the specified id.
|
default JSONObject |
getFirst(Query query)
Gets the first result json object by the specified query.
|
default List<JSONObject> |
getList(Query query)
Get json objects by the specified query.
|
String |
getName()
Gets the name of this repository.
|
List<JSONObject> |
getRandomly(int fetchSize)
Gets a list of json objects randomly with the specified fetch size.
|
boolean |
has(String id)
Determines a json object specified by the given id exists in this repository.
|
boolean |
hasTransactionBegun()
Whether the repository within a transaction.
|
boolean |
isWritable()
Whether the repository is writable.
|
void |
remove(Query query)
Removes json objects by the specified query.
|
void |
remove(String id)
Removes a json object by the specified id.
|
List<JSONObject> |
select(String statement,
Object... params)
Gets json objects by the specified query statement.
|
void |
setDebug(boolean debugEnabled)
Sets whether the repository is debug to show SQL with the specified flag.
|
void |
setWritable(boolean writable)
Sets whether the repository is writable with the specified flag.
|
void |
update(String id,
JSONObject jsonObject,
String... propertyNames)
Updates a certain json object specified by the given id with the specified new json object and property names.
|
String add(JSONObject jsonObject) throws RepositoryException
jsonObject - the specified json objectRepositoryException - repository exceptionvoid update(String id, JSONObject jsonObject, String... propertyNames) throws RepositoryException
id - the specified idjsonObject - the specified new json objectpropertyNames - the specified property names to update, update all properties if not specifiedRepositoryException - repository exceptionvoid remove(String id) throws RepositoryException
id - the specified idRepositoryException - repository exceptionvoid remove(Query query) throws RepositoryException
query - the specified queryRepositoryException - repository exceptionJSONObject get(String id) throws RepositoryException
id - the specified idnull if not foundRepositoryException - repository exceptionMap<String,JSONObject> get(Iterable<String> ids) throws RepositoryException
ids - the specified idsRepositoryException - repository exceptionboolean has(String id) throws RepositoryException
id - the given idtrue if it exists, otherwise falseRepositoryException - repository exceptionJSONObject get(Query query) throws RepositoryException
-1 or null) by caller (as the argument
Query.setPageCount(int)), the value will be used in the returned value. In other words, the page count result
will not be calculated by this interface, otherwise, the returned value pagination.paginationPageCount and
pagination.paginationRecordCount will be calculated with query condition.
Note: The order of elements of the returned result list is decided by datastore implementation, excepts
Query.addSort(java.lang.String, org.b3log.latke.repository.SortDirection) be invoked.
query - the specified query
{
"pagination": {
"paginationPageCount": 10, // May be specified by the specified query.pageCount
"paginationRecordCount": "100" // If query.pageCount has been specified with not -1 or null, this value will
be 0 also
},
"rslts": [{
"oId": "...."
}, ....]
}
RepositoryException - repository exceptiondefault List<JSONObject> getList(Query query) throws RepositoryException
query - the specified queryRepositoryException - repository exceptiondefault JSONObject getFirst(Query query) throws RepositoryException
query - the specified querynull if not foundRepositoryException - repository exceptionList<JSONObject> select(String statement, Object... params) throws RepositoryException
statement - the specified query statementparams - the specified parametersRepositoryException - repository exceptionList<JSONObject> getRandomly(int fetchSize) throws RepositoryException
fetchSize - the specified fetch sizeRepositoryException - repository exceptionlong count()
throws RepositoryException
-1 if not availableRepositoryException - repository exceptionlong count(Query query) throws RepositoryException
query - the specified query-1 if not availableRepositoryException - repository exceptionString getName()
Transaction beginTransaction()
Callers are responsible for explicitly calling Transaction.commit() or
Transaction.rollback() when they no longer need the Transaction. The Transaction
returned by this call will be considered the current transaction until one of the following happens:
Transaction returned by this methodTransaction will no longer be the current
transaction.
Transaction returned by this methodTransaction will no longer be the current
transaction.
boolean hasTransactionBegun()
true if the repository within a transaction, returns false otherwiseboolean isWritable()
true if it is writable, returns false otherwisevoid setWritable(boolean writable)
writable - the specified flag, true for writable, false otherwisevoid setDebug(boolean debugEnabled)
debugEnabled - the specified flag, true for enabled, false otherwiseCopyright © 2009–2019 B3log. All rights reserved.