You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: get-started.mdx
+18-41Lines changed: 18 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -49,61 +49,38 @@ const db = polybase.Polybase({
49
49
50
50
## Create a collection
51
51
52
-
Create collections using [Polybase Explorer](https://explorer.testnet.polybase.xyz) or the JavaScript SDK (`@polybase/client`).
52
+
You must create a collection before writing and reading data to Polybase. Create collections using [Polybase Explorer](https://explorer.testnet.polybase.xyz) **(recommended)** or programatically [using the JavaScript SDK](/collections#create-collection-programmatically).
53
+
53
54
54
55
Watch Shaki create a simple collection using the Polybase Explorer.
55
56
<iframe width="560" height="315" src="https://www.youtube.com/embed/EKHD7i1y4jc" title="Defining a collection in Polybase Explorer" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
56
57
57
-
<Info>
58
-
We suggest creating collections using [Polybase Explorer](https://explorer.testnet.polybase.xyz). You will need to first login and create an account.
59
-
</Info>
60
-
61
-
## Create a collection programmatically
62
-
63
-
If you want to create your collection programatically, see [Creating collection with applySchema](/collections#).
64
-
65
-
In this example we use the JavaScript SDK to create a collection called `City` that has `name` and `country` fields, and a `setCountry()` function. You can define multiple
66
-
collections in a single `applySchema` call.
58
+
Here's an example Schema:
67
59
68
60
```js
69
-
await db.applySchema(`
70
-
@public
71
-
collection City {
72
-
id: string;
73
-
name: string;
74
-
country?: string;
75
-
76
-
constructor (id: string, name: string) {
77
-
this.id = id;
78
-
this.name = name;
79
-
}
80
-
81
-
setCountry (country: string) {
82
-
this.country = country;
83
-
}
61
+
@public
62
+
collection City {
63
+
id: string;
64
+
name: string;
65
+
country?: string;
66
+
67
+
constructor (id: string, name: string) {
68
+
this.id = id;
69
+
this.name = name;
84
70
}
85
71
86
-
@public
87
-
collection Country {
88
-
id: string;
89
-
name: string;
90
-
91
-
constructor (id: string, name: string) {
92
-
this.id = id;
93
-
this.name = name;
94
-
}
72
+
setCountry (country: string) {
73
+
this.country = country;
95
74
}
96
-
`,
97
-
"your-namespace"
98
-
); // your-namespace is optional if you have defined a default namespace
75
+
}
99
76
```
100
77
101
-
You can create a collection using the [Explorer](https://explorer.testnet.polybase.xyz) **(recommended)** or by using the client library and calling the `applySchema` method on your polybase instance.
78
+
<Note>
79
+
A Polybase `collection` is just like an Ethereum `contract`, but instead of being for a single record, collections describes the rules for a set of records.
80
+
</Note>
102
81
103
-
A Polybase collection describes the rules for a collection of data, not just a single record (as is the case with other smart collection languages).
104
82
105
83
## Create a collection record
106
-
107
84
When you create a new record, the `constructor` function in your collection is called with the parameters you provide.
0 commit comments