Using Collections
Numerous Collections 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")
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.