Collection¶
-
class
pyArango.collection.
Collection
(database, jsonData)[source]¶ A document collection. Collections are meant to be instantiated by databases.
-
action
(method, action, **params)[source]¶ A generic ‘fct’ for interacting everything that does not have an assigned ‘fct’.
-
activateCache
(cacheSize)[source]¶ Activate the caching system.
Cached documents are only available through the __getitem__ interface.
-
bulkImport_json
(filename, onDuplicate='error', formatType='auto', **params)[source]¶ Bulk import from a file following the ArangoDB key-value format.
-
bulkImport_values
(filename, onDuplicate='error', **params)[source]¶ Bulk import from a file following the ArangoDB json format.
-
bulkSave
(docs, onDuplicate='error', **params)[source]¶ Parameter ‘docs’ must be either an iterable of documents or dictionaries.
This function will return the number of documents, created and updated, and will raise an UpdateError exception if there is at least one error. ‘params’ are any parameters from the ArangoDB documentation.
-
createDocument
(initDict=None)[source]¶ Create and return a completely empty document unless the initial document is set via ‘initDict’.
-
ensureFulltextIndex
(fields, minLength=None, name=None)[source]¶ Create a fulltext index if it does not already exist, then return it.
-
ensureGeoIndex
(fields, name=None)[source]¶ Create a geo index if it does not already exist, then return it.
-
ensureHashIndex
(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]¶ Create a hash index if it does not already exist, then return it.
-
ensurePersistentIndex
(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]¶ Create a persistent index if it does not already exist, then return it.
-
ensureSkiplistIndex
(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]¶ Create a skiplist index if it does not already exist, then return it.
-
ensureTTLIndex
(fields, expireAfter, unique=False, sparse=True, name=None)[source]¶ Create a TTL index if it does not already exist, then return it.
-
fetchAll
(rawResults=False, **queryArgs)[source]¶ Returns all the documents in the collection. You can use the optinal arguments ‘skip’ and ‘limit’:
fetchAlll(limit = 3, shik = 10)
-
fetchByExample
(exampleDict, batchSize, rawResults=False, **queryArgs)[source]¶ ‘exampleDict’ should be something like {‘age’ : 28}.
-
fetchDocument
(key, rawResults=False, rev=None)[source]¶ Fetche a document from the collection given its key.
This function always goes straight to the db and bypasses the cache. If you want to take advantage of the cache use the ‘__getitem__’ interface: collection[key]
-
fetchFirstExample
(exampleDict, rawResults=False)[source]¶ ‘exampleDict’ should be something like {‘age’ : 28}.
Return the first example found that matches the example, still in a ‘SimpleQuery’ object.
-
getIndexes
()[source]¶ Fill ‘self.indexes’ with all the indexes associated with the collection and return it.
-
getStatus
()[source]¶ Return a word describing the status of the collection (loaded, loading, deleted, unloaded, newborn) instead of a number, if you prefer the number it is in ‘self.status’.
-
getType
()[source]¶ Return a word describing the type of the collection (edges or ducments) instead of a number.
If you prefer the number it is in ‘self.type’.
-
classmethod
hasField
(fieldName)[source]¶ Return ‘True’ or ‘False’ whether the collection has field ‘K’ in its schema.
Use the dot notation for the nested fields: address.street
-
simpleQuery
(queryType, rawResults=False, **queryArgs)[source]¶ General interface for simple queries.
‘queryType’ takes the arguments known to the ArangoDB, for instance: ‘all’ or ‘by-example’. See the ArangoDB documentation for a list of valid ‘queryType’s. If ‘rawResults’ is set to ‘True’, the query will return dictionaries instead of ‘Document’ objetcs.
-
-
class
pyArango.collection.
Edges
(database, jsonData)[source]¶ The default edge collection. All edge Collections must inherit from it.
This one is meant to be called by the database.
-
getEdges
(vertex, inEdges=True, outEdges=True, rawResults=False)[source]¶ Return in, out, or both edges linked to a given document.
Vertex can be either a ‘Document’ object or a string for an ‘_id’. If ‘rawResults’ is set to ‘True’, return the results just as fetched without any processing. Otherwise, return a list of Edge objects.
-
getInEdges
(vertex, rawResults=False)[source]¶ An alias for ‘getEdges()’ that returns only the in ‘Edges’.
-
-
class
pyArango.collection.
Field
(validators=None, default=None)[source]¶ The class for defining pyArango fields.
Validators must be a list of validators.
‘default’ can also be a callable.
-
class
pyArango.collection.
DocumentCache
(cacheSize)[source]¶ Document cache for collection, with insert, deletes and updates in O(1).
-
class
pyArango.collection.
Collection_metaclass
[source]¶ The metaclass that takes care of keeping a register of all collection types.
-
classmethod
getCollectionClass
(name)[source]¶ Return the class object of a collection given its ‘name’.
-
classmethod
isCollection
(name) → bool[source]¶ return ‘True’ or ‘False’ whether ‘name’ is the name of collection.
-
classmethod
-
pyArango.collection.
getCollectionClass
(name) → bool[source]¶ Return ‘True’ or ‘False’ whether ‘name’ is the name of collection.
-
pyArango.collection.
isCollection
(name) → bool[source]¶ Return ‘True’ or ‘False’ whether ‘name’ is the name of a document collection.
-
pyArango.collection.
isDocumentCollection
(name) → bool[source]¶ Return ‘True’ or ‘False’ whether ‘name’ is the name of a document collection.