Using Collections

A Collection is a container of documents and files. It acts as a schemaless document database and a folder of files.

Creating and accessing Collections

In order to access a Collection in your application, you can use numerous.collection, which returns a Collection with the specified key.

Collections are automatically created the first time they are accessed.

collection = numerous.collection("my-collection")

Collection keys are scoped to an organization, meaning that if multiple apps use the same Collection keys, they will access the same data.

Creating and accessing Nested Collections

Collections can contain other Collections. You can use the collection method on a Collection to get a nested Collection with the specified key.

Nested Collections are automatically created the first time they are accessed.

parent = numerous.collection("parent-collection")
nested = parent.collection("nested-collection")

Accessing documents inside Collections

Documents can be accessed by their key or can otherwise be iterated over.

In order to access a specific document, use the document method:

collection = numerous.collection("my-collection")
document = collection.document("my-document")

In order to iterate over the documents in a Collection, use the documents method. You can filter documents by tags by providing tag_key and tag_value keyword arguments.

collection = numerous.collection("my-collection")
 
for document in collection.documents():
    print(document.get())
 
for document in collections.documents(tag_key="my-tag-key", tag_value="my-tag-value"):
    print(document.get())

Collections in subscription apps

Collections exist within the organization that deploys the app.

It is on our immediate roadmap to store data in the subscribing organization instead, in order to ensure correct ownership of data produced by apps.