Skip to content

Commit 6305ebe

Browse files
authored
Merge pull request #46 from nitrictech/feature/context-api
feat: context based faas api
2 parents cddd871 + fb79c84 commit 6305ebe

31 files changed

Lines changed: 1030 additions & 1000 deletions

examples/documents/delete.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_delete():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
document = docs.collection("products").doc("nitric")
910

1011
await document.delete()
12+
13+
1114
# [END snippet]

examples/documents/get.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_get():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
document = docs.collection("products").doc("nitric")
910

1011
product = await document.get()
12+
13+
1114
# [END snippet]

examples/documents/paged_results.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_paged_results():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
query = docs.collection("Customers").query().where("active", "==", True).limit(100)
@@ -13,4 +14,6 @@ async def documents_paged_results():
1314
# Fetch next page
1415
if results.paging_token:
1516
results = await query.page_from(results.paging_token).fetch()
17+
18+
1619
# [END snippet]

examples/documents/query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_query():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
query = docs.collection("Customers").query()
910

1011
# Execute query
1112
results = await query.fetch()
13+
14+
1215
# [END snippet]

examples/documents/query_filter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_query_filter():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
query = docs.collection("Customers").query().where("country", "==", "US").where("age", ">=", 21)
910

1011
results = await query.fetch()
12+
13+
1114
# [END snippet]

examples/documents/query_limits.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_query_limits():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
query = docs.collection("Customers").query().limit(1000)
910

1011
results = await query.fetch()
12+
13+
1114
# [END snippet]

examples/documents/refs.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
def documents_refs():
5-
# [START snippet]
6-
docs = Documents()
6+
# [START snippet]
7+
docs = Documents()
8+
9+
# create a reference to a collection named 'products'
10+
products = docs.collection("products")
11+
12+
# create a reference to a document with the id 'nitric'
13+
nitric = products.doc("nitric")
714

8-
# create a reference to a collection named 'products'
9-
products = docs.collection("products")
1015

11-
# create a reference to a document with the id 'nitric'
12-
nitric = products.doc("nitric")
1316
# [END snippet]

examples/documents/set.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_set():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
document = docs.collection("products").doc("nitric")
@@ -16,4 +17,6 @@ async def documents_set():
1617
}
1718
)
1819
)
20+
21+
1922
# [END snippet]

examples/documents/streamed.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_streamed():
5-
# [START snippet]
6+
# [START snippet]
67
docs = Documents()
78

89
query = docs.collection("Customers").query()
910

1011
async for doc in query.stream():
1112
# Process doc stream...
1213
print(doc.content)
13-
# [END snippet]
14+
15+
16+
# [END snippet]
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# [START import]
22
from nitric.api import Documents
3+
34
# [END import]
45
async def documents_sub_col_query():
5-
# [START snippet]
6-
docs = Documents()
6+
# [START snippet]
7+
docs = Documents()
8+
9+
query = docs.collection("Customers").collection("Orders").query()
10+
11+
results = await query.fetch()
712

8-
query = (docs.collection("Customers")
9-
.collection("Orders")
10-
.query())
1113

12-
results = await query.fetch()
1314
# [END snippet]

0 commit comments

Comments
 (0)