CreDB  0.1.0
Public Member Functions | List of all members
Collection Class Referenceabstract

#include <Collection.h>

Public Member Functions

virtual std::vector< json::Document > diff (const std::string &key, version_number_t version1, version_number_t version2)=0
 Get the changes between two versions of the same object.
 
virtual bool create_index (const std::string &name, const std::vector< std::string > &paths)=0
 
virtual cow::ValuePtr call (const std::string &program_name, const std::vector< std::string > &args)=0
 
virtual bool drop_index (const std::string &name)=0
 
virtual const std::string & name ()=0
 
virtual uint32_t size ()
 
virtual bool set_trigger (std::function< void()> lambda)=0
 Set a function that will be triggered when the collection is modified, This will overwrite any existing trigger for this collection. More...
 
virtual bool unset_trigger ()=0
 Unset modification notifications for this collection.
 
virtual uint32_t count (const json::Document &predicates=json::Document(""))=0
 Return the number of objects in this collection matching a specified predicate.
 
virtual event_id_t add (const std::string &path, const json::Document &doc)=0
 Increment the vale of an object. More...
 
virtual std::tuple< std::string, event_id_tput (const json::Document &doc)=0
 Insert a new value and generate a unique key for it.
 
virtual event_id_t put (const std::string &key, const json::Document &doc)=0
 Insert or update the value of an object. More...
 
virtual event_id_t put_code (const std::string &key, const std::string &code)=0
 Create a new object holding executable code. More...
 
virtual event_id_t put_code_from_file (const std::string &key, const std::string &filename)=0
 Create a new object holding executable code loaded from a specified file. More...
 
virtual event_id_t put_from_file (const std::string &key, const std::string &filename)=0
 Insert or update an object to store the contents in a file. More...
 
virtual bool clear ()=0
 
virtual event_id_t remove (const std::string &key)=0
 Remove an object from the collection. More...
 
virtual json::Document get (const std::string &key, event_id_t &event_id)=0
 Get a value of an object. More...
 
virtual bool has_object (const std::string &key)=0
 Check whether an object exists. More...
 
virtual bool check (const std::string &key, const json::Document &predicate)=0
 Check whether an object matches a certain predicate. More...
 
virtual json::Document get_with_witness (const std::string &key, event_id_t &event_id, Witness &witness)=0
 Get a value and return a witness for it.
 
virtual std::vector< json::Document > get_history (const std::string &key)=0
 Get the history of changes to a specified object.
 
virtual std::tuple< std::string, json::Document > find_one (const json::Document &predicates=json::Document(""), const std::vector< std::string > &projection={})=0
 returns the first object that fits a predicate More...
 
virtual std::vector< std::tuple< std::string, json::Document > > find (const json::Document &predicates=json::Document(""), const std::vector< std::string > &projection={}, int32_t limit=-1)=0
 find all objects that fit a predicate More...
 
json::Document get (const std::string &key)
 Get a value of an object. More...
 

Detailed Description

Handle to access and modify a collection A collection corresponds to a "table" in RDBMs

Member Function Documentation

◆ add()

virtual event_id_t add ( const std::string &  path,
const json::Document &  doc 
)
pure virtual

Increment the vale of an object.

Parameters
pathThe path of the object. Should be of form "name[.field]*"
docThe value to be incremented with. Should either be numeric or string (strings will be appened)

◆ call()

virtual cow::ValuePtr call ( const std::string &  program_name,
const std::vector< std::string > &  args 
)
pure virtual

Call a function that is stored as an object on the server

If the function executes successfully the return value of this call will be the return value of the serve side function. Otherwise, this call will throw an exception.

◆ check()

virtual bool check ( const std::string &  key,
const json::Document &  predicate 
)
pure virtual

Check whether an object matches a certain predicate.

Parameters
keyThe primary key of the object
predicateThe predicate to check
Returns
True iff the object exists and matches the predicate, False otherwise

◆ clear()

virtual bool clear ( )
pure virtual

Remove all objects stored in this collection

◆ create_index()

virtual bool create_index ( const std::string &  name,
const std::vector< std::string > &  paths 
)
pure virtual

Create a secondary index for this collection This index will cover all objects containing the paths specified.

Parameters
nameThe identifier of the index. Must be unique for this collection
pathsThe paths the index will cover

◆ drop_index()

virtual bool drop_index ( const std::string &  name)
pure virtual

Remove the specified secondary index

Parameters
nameThe identifier of the index to be removed

◆ find()

virtual std::vector<std::tuple<std::string, json::Document> > find ( const json::Document &  predicates = json::Document(""),
const std::vector< std::string > &  projection = {},
int32_t  limit = -1 
)
pure virtual

find all objects that fit a predicate

Parameters
predicates[optional] the object has to match all specified predicates. if no predicate is specified all objects in the collection are returned.
projection[optional] only return the fields specified
limit[optional] only return up to a certain number of objects

◆ find_one()

virtual std::tuple<std::string, json::Document> find_one ( const json::Document &  predicates = json::Document(""),
const std::vector< std::string > &  projection = {} 
)
pure virtual

returns the first object that fits a predicate

Parameters
predicates[optional] the object has to match all specified predicates
projection[optional] only return the fields specified

◆ get() [1/2]

virtual json::Document get ( const std::string &  key,
event_id_t event_id 
)
pure virtual

Get a value of an object.

Parameters
keyThe primary key of the object
event_id[out] The event identifier of the most recent version of the object

◆ get() [2/2]

json::Document get ( const std::string &  key)
inline

Get a value of an object.

Parameters
keyThe primary key of the object

◆ has_object()

virtual bool has_object ( const std::string &  key)
pure virtual

Check whether an object exists.

Parameters
keyThe primary key of the object
Returns
True if the object exists, False otherwise

◆ name()

virtual const std::string& name ( )
pure virtual

What is the name of this collection?

◆ put()

virtual event_id_t put ( const std::string &  key,
const json::Document &  doc 
)
pure virtual

Insert or update the value of an object.

Parameters
keyThe path of the object. Should be of form "name[.field]*"
docThe value to be stored

◆ put_code()

virtual event_id_t put_code ( const std::string &  key,
const std::string &  code 
)
pure virtual

Create a new object holding executable code.

Parameters
keyThe key to store the new object in
codeSource code of the code to be stored. Will be compiled to byte code on the client side.

◆ put_code_from_file()

virtual event_id_t put_code_from_file ( const std::string &  key,
const std::string &  filename 
)
pure virtual

Create a new object holding executable code loaded from a specified file.

Parameters
keyThe key to store the new object in
filenameName of the file that contains the sourcecode

◆ put_from_file()

virtual event_id_t put_from_file ( const std::string &  key,
const std::string &  filename 
)
pure virtual

Insert or update an object to store the contents in a file.

Parameters
keyThe identifier of the object
filenameName of the file containing the JSON data

◆ remove()

virtual event_id_t remove ( const std::string &  key)
pure virtual

Remove an object from the collection.

Parameters
keyThe identifier of the object to be removed

◆ set_trigger()

virtual bool set_trigger ( std::function< void()>  lambda)
pure virtual

Set a function that will be triggered when the collection is modified, This will overwrite any existing trigger for this collection.

Note
Make sure this function does not go out of scope before you unset the trigger!

◆ size()

virtual uint32_t size ( )
inlinevirtual

How many objects are there in this collection?


The documentation for this class was generated from the following file: