CollectionReference
A reference to a collection of JSON documents in CAWS.
Obtained from CarpService.collection or DocumentReference.collection. Collections let an app store and query its own documents, like app resources or user notes, per study.
Note that the collection / document structure is like this:
collection/document/collection/document/...
I.e., that a collection holds a list of documents, which each can hold a list of collections, etc. For example, the following
activities/running/geopositions/pos_1
is a reference to the geoposition document pos_1 in the collection geopositions in the document running in the collection activities.
- Inheritance
-
- Object
- CarpReference
- CollectionReference
Properties
cawsPath
The full CARP Web Service (CAWS) path to this collection.
collectionUri
The full URI for the collection endpoint for this CollectionReference.
collectionUriByID
The full URI for the collection endpoint for this CollectionReference by its unique id.
documents
id
ID of the referenced collection.
Is null until read from the server with get, and -1 after delete.
name
The name of the referenced collection.
path
Returns the path of this collection (relative to the root of the web service).
studyId
The id of the study for this collection.
Methods
add
Adds a data document to this collection and returns a DocumentReference to this document.
If no name is provided, an auto-generated name is used. If no data is provided, this can be set later using the DocumentReference.setData method.
delete
Deletes the collection referred to by this CollectionReference.
document
- String? name
Returns a DocumentReference with the provided name in this collection.
If no name is provided, an auto-generated name is used.
get
Reads the collection referenced by this CollectionReference from the server, and updates id and path.
Returns this reference. Throws a CarpServiceRequestException if the collection does not exist on the server.
rename
Renames this collection to newName.
toString
A string representation of this object.
Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.
Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.