9 #include <mongocxx/instance.hpp>
10 #include <mongocxx/database.hpp>
11 #include <mongocxx/client.hpp>
12 #include <mongocxx/uri.hpp>
15 using namespace mongocxx;
26 explicit VFS_mongo_cache_entry(
VFS_mongo *mongo, QString path,
bool debug,
int flushInterval,
int expireInterval,
bool create=
false,
bool container=
false, QJsonObject createData=QJsonObject());
29 virtual bool valid(QString &reason);
58 virtual QByteArray
icon();
69 bool createDocument( QString path, QJsonObject o, quint64 &
size,
bool container=
false );
71 quint64
writeDocument( QString path, QJsonObject o,
bool container=
false );
99 virtual const char *
what()
const throw();
A pure virtual class which must be subclassed for data storage.
static const quint64 DEFAULT_DATACACHE_SIZE
The default size to create a cache. Defaults to 100mb.
A base class for creating storage nodes in VFS.
A subclass of VFS_datastore_cache_entry, used for mongo database access.
virtual ~VFS_mongo_cache_entry()
VFS_mongo_cache_entry destructor.
QString _path
The path associated with this cache entry.
virtual bool isContainer()
Return the container-ness of this entry.
VFS_mongo * _mongo
The VFS_mongo instance that owns this item's cache.
virtual void flush()
Actually write the document to the database.
virtual bool valid(QString &reason)
If the file or directory does not exist or is not readable, _valid is set to false.
bool _container
The entry is a container.
VFS_mongo_cache_entry(VFS_mongo *mongo, QString path, bool debug, int flushInterval, int expireInterval, bool create=false, bool container=false, QJsonObject createData=QJsonObject())
A subclass of VFS_mongo_exception signalling a problem with the collection path of an operation.
VFS_mongo_collectionException(QString m)
VFS_mongo_collectionException constructor.
virtual ~VFS_mongo_collectionException()
A subclass of VFS_mongo_exception signalling a problem with the path of a read or write operation.
virtual ~VFS_mongo_directoryException()
VFS_mongo_directoryException(QString m)
VFS_mongo_directoryException constructor.
A subclass of VFS_mongo_exception signalling a problem with the path of a read or write operation.
virtual ~VFS_mongo_entryException()
VFS_mongo_entryException(QString m)
VFS_mongo_entryException constructor.
Base class for VFS_mongo_exception subclasses.
virtual const char * what() const
Fetch the exception message, in the style of std::exception.
VFS_mongo_exception(QString m)
VFS_mongo_exception constructor.
QString _message
This exception's message.
virtual ~VFS_mongo_exception()
A VFS_datastore subclass for accessing data in Mongo.
virtual QByteArray icon()
The "disk" icon found in the VFS_icons library.
virtual void subscribe(VFS_request *r)
Subscribe to changes on a database document.
client _client
The Mongo (mongocxx) client object.
static instance _instance
The global mongocxx instance. There should only ever be one of these.
bool createDocument(QString path, QJsonObject o, quint64 &size, bool container=false)
Create a new document in the database if it doesn't exist.
QJsonObject readDocument(QString path, quint64 &size, bool &container)
Search for a document by "_path" in the database.
int _flushInterval
Interval for cache entries to flush, in milliseconds.
virtual void submit(VFS_request *r)
Submit data to a file, applying the data as a diff.
virtual void metadata(VFS_request *r)
Fetch the metadata for a database document.
database _database
The Mongo (mongocxx) database object.
virtual QString reportDetails()
Report the current cache usage.
bool removeDocument(QString path)
Remove a document from the database.
virtual void write(VFS_request *r)
Write data to a database document.
QString _databaseName
The name of the database to use.
int _expireInterval
Interval for cache entries to expire, in milliseconds.
quint64 writeDocument(QString path, QJsonObject o, bool container=false)
Update a document in the database.
QString _url
The database url for this node to connect to, for instance mongodb://localhost:27017.
QString _collection
The collection to use.
bool _createCollection
If a reference is made to a non-existent collection, create it, or throw an error.
virtual void rm(VFS_request *r)
Attempt to delete a file.
virtual void ls(VFS_request *r)
List the contents of a collection using a Mongo find() on the path.
Q_INVOKABLE VFS_mongo(QString uri, QString db, QString collection, quint64 size=VFS_datastore_cache::DEFAULT_DATACACHE_SIZE, bool debug=false, int flushInterval=5000, int expireInterval=60000, bool createCollection=false)
Create a VFS_Mongo node.
virtual void read(VFS_request *r)
Read the contents of a database document.
bool createCollection(QString name)
Create a collection.
The base class for all requests between nodes.