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.

checksum()[source]

Return the current checksum.

count()[source]

Return the number of documents in the collection.

createDocument(initDict=None)[source]

Create and return a completely empty document unless the initial document is set via ‘initDict’.

deactivateCache()[source]

Deactivate the caching system.

delete()[source]

Delete the collection from the database.

empty()[source]

Alias for truncate.

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.

ensureIndex(index_type, fields, name=None, **index_args)[source]

Create an index of any type.

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.

figures()[source]

A more elaborate version of ‘count’, see the ArangoDB documentation for more.

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

load()[source]

Load collection in memory.

properties()[source]

Return the current properties.

restoreIndexes(indexes_dct=None)[source]

Restore all previously removed indexes.

revision()[source]

Return the current revision.

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.

truncate()[source]

Delete every document in the collection.

unload()[source]

Unload collection from memory.

validatePrivate(field, value)[source]

Validate a private field value.

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.

createEdge(initValues=None)[source]

Create an edge populated with defaults.

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’.

getOutEdges(vertex, rawResults=False)[source]

An alias for ‘getEdges()’ that returns only the out ‘Edges’.

classmethod validateField(fieldName, value)[source]

Check if ‘value’ is valid for field ‘fieldName’.

If the validation fails, raise a ‘SchemaViolation’ or a ‘ValidationError’. For nested dicts ex: {address : { street: xxx} }, ‘fieldName’ can take the form ‘address.street’.

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.

validate(value)[source]

Check the validity of ‘value’ given the list of validators.

class pyArango.collection.DocumentCache(cacheSize)[source]

Document cache for collection, with insert, deletes and updates in O(1).

delete(_key)[source]

Remove a document from the cache.

getChain()[source]

Return a list of keys representing the chain of documents.

stringify() → str[source]

Return a pretty string of ‘getChain()’.

class pyArango.collection.CachedDoc(document, prev, nextDoc)[source]

A cached document.

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 isDocumentCollection(name) → bool[source]

Return ‘True’ or ‘False’ whether ‘name’ is the name of a document collection.

classmethod isEdgeCollection(name) → bool[source]

Return ‘True’ or ‘False’ whether ‘name’ is the name of an edge collection.

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.

pyArango.collection.isEdgeCollection(name) → bool[source]

Return ‘True’ or ‘False’ whether ‘name’ is the name of an edge collection.

pyArango.collection.getCollectionClasses() → bool[source]

Return a dictionary of all defined collection classes.