Documents
Documents( collection )
Documents( collection )
Documents( collection )
Documents( collection )
documents( collection )
Documents( collection )
Description
The Documents
function returns the set of documents that exist in the
specified collection
.
Before the Documents
function was introduced, you needed to create an
index just to facilitate retrieving documents from a collection. See the
Indexing tutorials for details.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
A reference to the collection from which documents should be collected. |
Returns
A SetRef which represents all of the documents
in the specified collection
.
Examples
The following query returns three documents in the Letters
collection
(established as part of the
Index tutorials):
Value result = await client.Query(
Paginate(Documents(Collection("Letters")), size: 3)
);
Console.WriteLine("{result}", result)
ObjectV(after: Arr(RefV(id = "104", collection = RefV(id = "Letters", collection = RefV(id = "collections")))),data: Arr(RefV(id = "101", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "102", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "103", collection = RefV(id = "Letters", collection = RefV(id = "collections")))))
result, err := client.Query(
f.Paginate(f.Documents(f.Collection("Letters")), f.Size(3)))
if (err != nil) {
fmt.Println(err)
} else {
fmt.Println(result)
}
map[after:[{104 0xc0000b7470 0xc0000b7470 <nil>}] data:[{101 0xc0000b7620 0xc0000b7620 <nil>} {102 0xc0000b77d0 0xc0000b77d0 <nil>} {103 0xc0000b7980 0xc0000b7980 <nil>}]]
System.out.println(
client.query(
Paginate(Documents(Collection("Letters"))).size(3)
).get());
{after: [ref(id = "104", collection = ref(id = "Letters", collection = ref(id = "collections")))], data: [ref(id = "101", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "102", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "103", collection = ref(id = "Letters", collection = ref(id = "collections")))]}
client.query(
q.Paginate(q.Documents(q.Collection('Letters')), { size: 3 }),
)
.then((ret) => console.log(ret))
{ after: [ Ref(Collection("Letters"), "104") ],
data:
[ Ref(Collection("Letters"), "101"),
Ref(Collection("Letters"), "102"),
Ref(Collection("Letters"), "103") ] }
print(client.query(
q.paginate(q.documents(q.collection('Letters')), size = 3)
))
{'after': [Ref(id=104, collection=Ref(id=Letters, collection=Ref(id=collections)))], 'data': [Ref(id=101, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=102, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=103, collection=Ref(id=Letters, collection=Ref(id=collections)))]}
println(Await.result(
client.query(
Paginate(Documents(Collection("Letters")), size = 3),
),
5.seconds
))
{after: [ref(id = "104", collection = ref(id = "Letters", collection = ref(id = "collections")))], data: [ref(id = "101", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "102", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "103", collection = ref(id = "Letters", collection = ref(id = "collections")))]}
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!