Skip to content

Commit c08ece0

Browse files
author
Polybase CI
committed
Merge remote-tracking branch 'origin/main' into release
2 parents 85aa81d + c5b030d commit c08ece0

File tree

5 files changed

+167
-4
lines changed

5 files changed

+167
-4
lines changed

Diff for: .github/workflows/release.branch.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Create PR for Release Branch
2+
3+
on:
4+
create:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
create_release_branch:
10+
runs-on: ubuntu-latest
11+
if: startsWith(github.ref, 'refs/heads/release-')
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set Version as env var
19+
run: |
20+
branch_name=$(echo ${{ github.ref }} | sed 's/refs\/heads\///')
21+
VERSION=${branch_name#release-}
22+
echo "VERSION=$VERSION" >> $GITHUB_ENV
23+
24+
- name: Set up JQ
25+
run: |
26+
sudo apt-get install jq
27+
28+
- name: Update JSON file
29+
run: |
30+
jq '.versions[0] = env.VERSION' mint.json > temp.json && mv temp.json mint.json
31+
32+
- name: Commit changes
33+
run: |
34+
git config --local user.email user.email "hello@polybase.xyz"
35+
git config --local user.name "Polybase CI"
36+
git add .
37+
git commit -m "Bump version" || echo "No changes to commit"
38+
git push
39+
40+
- name: Create Pull Request
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }}
43+
run: |
44+
branch_name=$(echo ${{ github.ref }} | sed 's/refs\/heads\///')
45+
curl -X POST \
46+
-H "Authorization: token $GITHUB_TOKEN" \
47+
-H "Accept: application/vnd.github.v3+json" \
48+
https://api.github.com/repos/${{ github.repository }}/pulls \
49+
-d '{
50+
"title": "Release 'v$VERSION'",
51+
"body": "This is an automated PR for release '$VERSION'",
52+
"head": "'$branch_name'",
53+
"base": "main"
54+
}'

Diff for: .github/workflows/release.pr.merge.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
jobs:
11+
12+
release:
13+
runs-on: ubuntu-latest
14+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release-')
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
ref: release
20+
token: ${{ secrets.ADMIN_TOKEN }}
21+
22+
- name: Configure Git
23+
run: |
24+
git config --global user.email "hello@polybase.xyz"
25+
git config --global user.name "Polybase CI"
26+
27+
- name: Get PR Info
28+
run: |
29+
PR_TITLE="${{ github.event.pull_request.title }}"
30+
PR_DESC="${{ github.event.pull_request.body }}"
31+
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
32+
PR_VERSION="${PR_BRANCH#*release-}"
33+
34+
echo "PR Title: $PR_TITLE"
35+
echo "PR Description: $PR_DESC"
36+
echo "PR Branch: $PR_BRANCH"
37+
echo "PR Version: $PR_VERSION"
38+
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
39+
40+
- name: Merge main into release (to deploy)
41+
run: |
42+
git fetch origin main
43+
git merge --no-edit origin/main
44+
45+
- name: Create Tag
46+
id: create_tag
47+
run: |
48+
git tag $PR_VERSION
49+
echo ::set-output name=tag::${PR_VERSION}
50+
51+
- name: Push Changes and Tags
52+
run: |
53+
git push origin HEAD:release --tags

Diff for: collections.mdx

+3-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ The following types are supported:
200200
- `bytes`
201201
- `PublicKey`
202202
- `Collection`
203-
- `string[]`, `number[]`, `boolean[]` and `Collection*[]`
203+
- `string[]`, `number[]`, `boolean[]`, `PublicKey[]` and `Collection*[]`
204204
- `map<string | number, T>`
205205

206206
Where `Collection*` is the name of a specific collection in the same namespace.
@@ -324,7 +324,7 @@ and the hexidecimal representation of the 64 byte public key.
324324

325325
#### Arrays
326326

327-
You can create arrays of `string`, `number`, `boolean` and `Collection` type. For example:
327+
You can create arrays of `string`, `number`, `boolean`, `PublicKey` and `Collection` type. For example:
328328

329329
```js
330330
@public
@@ -334,6 +334,7 @@ collection User {
334334
ages: number[];
335335
attempts: boolean[];
336336
friends: User[];
337+
keys: PublicKey[];
337338
}
338339
```
339340

Diff for: mint.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "Polybase",
3+
"versions": [
4+
"0.6.0"
5+
],
36
"logo": {
47
"light": "/logo/light.svg",
58
"dark": "/logo/dark.svg"
@@ -114,4 +117,4 @@
114117
"apiHost": "https://a.polybase.xyz"
115118
}
116119
}
117-
}
120+
}

Diff for: read.mdx

+53-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ const db = new Polybase({ defaultNamespace: "your-namespace" });
2222
const collectionReference = db.collection("cities");
2323

2424
async function getRecord () {
25-
const { data, block } = await collectionReference.record("id").get();
25+
const record = await collectionReference.record("id").get();
26+
27+
// Get data from the record
28+
const { data } = record; // or const data = record.data
29+
30+
// Record is CollectionRecordResponse instance, so you can also get again to refresh
31+
const updatedRecord = record.get();
2632
}
2733
```
2834

@@ -74,6 +80,12 @@ const collectionReference = db.collection("cities");
7480

7581
export async function listRecordsWithFilter () {
7682
const records = await collectionReference.where("country", "==", "UK").get();
83+
84+
// Array of records is available under the data property
85+
const { data, cursor } = records;
86+
87+
// Records is QueryResponse, so we can use it to get the next page of results
88+
await records.next();
7789
}
7890

7991
```
@@ -110,3 +122,43 @@ const collectionReference = db
110122
}
111123
);
112124
```
125+
126+
## Pagination
127+
128+
You can paginate through your results using the cursor returned from the
129+
`.get()` method, or by using the built-in `.next()`
130+
131+
### Pagination with cursor
132+
133+
Use the cursor response with `.before()` and `.after()` to paginate through
134+
collection data.
135+
136+
```js
137+
const db = new Polybase({ defaultNamespace: "your-namespace" });
138+
const collectionReference = await db.collection("cities");
139+
140+
// First page
141+
const { data, cursor } = await collectionReference.get();
142+
143+
// Next page
144+
const next = await collectionReference.after(cursor.after).get();
145+
146+
// Previous page
147+
const previous = await collectionReference.before(cursor.before).get();
148+
```
149+
150+
### Pagination with next() or previous()
151+
152+
To simplify this process, a `next()` and `previous()` helper method is provided on the response.
153+
154+
```js
155+
const db = new Polybase({ defaultNamespace: "your-namespace" });
156+
const collectionReference = await db.collection("cities");
157+
158+
// First page
159+
const first = await collectionReference.get();
160+
161+
// Next pages
162+
const second = await first.next();
163+
const third = await second.next();
164+
```

0 commit comments

Comments
 (0)