Collection

class pyArango.collection.Collection(database, jsonData)[source]

A document collection. Collections are meant to be instanciated by databases

action(method, action, **params)[source]

a generic fct for interacting everything that doesn’t 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 repecting arango’s key/value format

bulkImport_values(filename, onDuplicate='error', **params)[source]

bulk import from a file repecting arango’s json format

bulkSave(docs, onDuplicate='error', **params)[source]

Parameter docs must be either an iterrable of documents or dictionnaries. This function will return the number of documents, created and updated, and will raise an UpdateError exception if there’s at least one error. params are any parameters from arango’s documentation

checksum()[source]

returns the current checksum

count()[source]

returns the number of documents in the collection

createDocument(initDict=None)[source]

create and returns a completely empty document or one populated with initDict

deactivateCache()[source]

deactivate the caching system

delete()[source]

deletes the collection from the database

empty()[source]

alias for truncate

ensureFulltextIndex(fields, minLength=None, name=None)[source]

Creates a fulltext index if it does not already exist, and returns it

ensureGeoIndex(fields, name=None)[source]

Creates a geo index if it does not already exist, and returns it

ensureHashIndex(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]

Creates a hash index if it does not already exist, and returns it

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

Creates an index of any type.

ensurePersistentIndex(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]

Creates a persistent index if it does not already exist, and returns it

ensureSkiplistIndex(fields, unique=False, sparse=True, deduplicate=False, name=None)[source]

Creates a skiplist index if it does not already exist, and returns it

ensureTTLIndex(fields, expireAfter, unique=False, sparse=True, name=None)[source]

Creates a TTL index if it does not already exist, and returns it

fetchAll(rawResults=False, **queryArgs)[source]

Returns all the documents in the collection. You can use the optinal arguments ‘skip’ and ‘limit’:

fetchAll(limit = 3, skip = 10)

fetchByExample(exampleDict, batchSize, rawResults=False, **queryArgs)[source]

exampleDict should be something like {‘age’ : 28}

fetchDocument(key, rawResults=False, rev=None)[source]

Fetches a document from the collection given it’s 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}. returns only a single element but still in a SimpleQuery object. returns the first example found that matches the example

figures()[source]

a more elaborate version of count, see arangodb docs for more infos

getIndexes()[source]

Fills self.indexes with all the indexes associates with the collection and returns it

getStatus()[source]

returns a word describing the status of the collection (loaded, loading, deleted, unloaded, newborn) instead of a number, if you prefer the number it’s in self.status

getType()[source]

returns a word describing the type of the collection (edges or ducments) instead of a number, if you prefer the number it’s in self.type

classmethod hasField(fieldName)[source]

returns True/False wether the collection has field K in it’s schema. Use the dot notation for the nested fields: address.street

load()[source]

loads collection in memory

properties()[source]

returns the current properties

restoreIndexes(indexes_dct=None)[source]

restores all previously removed indexes

revision()[source]

returns the current revision

simpleQuery(queryType, rawResults=False, **queryArgs)[source]

General interface for simple queries. queryType can be something like ‘all’, ‘by-example’ etc… everything is in the arango doc. If rawResults, the query will return dictionaries instead of Document objetcs.

truncate()[source]

deletes every document in the collection

unload()[source]

unloads 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]

returns in, out, or both edges liked to a given document. vertex can be either a Document object or a string for an _id. If rawResults a arango results will be return as fetched, if false, will return a liste 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]

checks if ‘value’ is valid for field ‘fieldName’. If the validation is unsuccessful, raises 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]

checks the validity of ‘value’ given the lits of validators

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

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

delete(_key)[source]

removes a document from the cache

getChain()[source]

returns a list of keys representing the chain of documents

stringify()[source]

a pretty str version 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)[source]

return true or false wether ‘name’ is the name of collection.

classmethod isDocumentCollection(name)[source]

return true or false wether ‘name’ is the name of a document collection.

classmethod isEdgeCollection(name)[source]

return true or false wether ‘name’ is the name of an edge collection.

pyArango.collection.getCollectionClass(name)[source]

return true or false wether ‘name’ is the name of collection.

pyArango.collection.isCollection(name)[source]

return true or false wether ‘name’ is the name of a document collection.

pyArango.collection.isDocumentCollection(name)[source]

return true or false wether ‘name’ is the name of a document collection.

pyArango.collection.isEdgeCollection(name)[source]

return true or false wether ‘name’ is the name of an edge collection.

pyArango.collection.getCollectionClasses()[source]

returns a dictionary of all defined collection classes