Skip to content

Commit ec5adc2

Browse files
Update SDK docs
1 parent 2042559 commit ec5adc2

File tree

17 files changed

+2124
-1944
lines changed

17 files changed

+2124
-1944
lines changed

modus/sdk/assemblyscript/collections.mdx

Lines changed: 219 additions & 221 deletions
Large diffs are not rendered by default.

modus/sdk/assemblyscript/console.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The Modus Console APIs allow you to capture information from your functions,
1111
such as errors and other information that can help you debug your functions.
1212

1313
<Info>
14-
Unlike other APIs, the Console namespace is globally available by default in
15-
all functions, you don't need to import it.
14+
Unlike other APIs, the `console` namespace is globally available by default in
15+
all AssemblyScript functions, you don't need to import it.
1616
</Info>
1717

1818
The Console APIs mimic the behavior of the AssemblyScript
@@ -40,10 +40,10 @@ The APIs in the `console` namespace are below, organized by category.
4040
Asserts that a condition is true, and logs an error if it's not.
4141

4242
```ts
43-
console.assert(assertion: any, message?: string): void
43+
function assert<T>(assertion: T, message?: string): void
4444
```
4545

46-
<ResponseField name="assertion" type="any" required>
46+
<ResponseField name="assertion" required>
4747
The condition to assert. Typically a boolean value. In the case of an object,
4848
asserts that the object isn't `null`.
4949
</ResponseField>
@@ -59,7 +59,7 @@ console.assert(assertion: any, message?: string): void
5959
Generate a log message, with no particular logging level.
6060

6161
```ts
62-
console.log(message?: string): void
62+
function log(message?: string): void
6363
```
6464

6565
<ResponseField name="message" type="string">
@@ -71,7 +71,7 @@ console.log(message?: string): void
7171
Generate a log message with the "debug" logging level.
7272

7373
```ts
74-
console.debug(message?: string): void
74+
function debug(message?: string): void
7575
```
7676

7777
<ResponseField name="message" type="string">
@@ -83,7 +83,7 @@ console.debug(message?: string): void
8383
Generate a log message with the "info" logging level.
8484

8585
```ts
86-
console.info(message?: string): void
86+
function info(message?: string): void
8787
```
8888

8989
<ResponseField name="message" type="string">
@@ -95,7 +95,7 @@ console.info(message?: string): void
9595
Generate a log message with the "warning" logging level.
9696

9797
```ts
98-
console.warn(message?: string): void
98+
function warn(message?: string): void
9999
```
100100

101101
<ResponseField name="message" type="string">
@@ -107,7 +107,7 @@ console.warn(message?: string): void
107107
Generate a log message with the "error" logging level.
108108

109109
```ts
110-
console.error(message?: string): void
110+
function error(message?: string): void
111111
```
112112

113113
<ResponseField name="message" type="string">
@@ -121,7 +121,7 @@ console.error(message?: string): void
121121
Starts a new timer using the specified label.
122122

123123
```ts
124-
console.time(label?: string): void
124+
function time(label?: string): void
125125
```
126126

127127
<ResponseField name="label" type="string">
@@ -133,7 +133,7 @@ console.time(label?: string): void
133133
Logs the current value of a timer previously started with `console.time`.
134134

135135
```ts
136-
console.timeLog(label?: string): void
136+
function timeLog(label?: string): void
137137
```
138138

139139
<ResponseField name="label" type="string">
@@ -146,7 +146,7 @@ Logs the current value of a timer previously started with `console.time`, and
146146
discards the timer.
147147

148148
```ts
149-
console.timeEnd(label?: string): void
149+
function timeEnd(label?: string): void
150150
```
151151

152152
<ResponseField name="label" type="string">

modus/sdk/assemblyscript/dgraph.mdx

Lines changed: 79 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -28,99 +28,110 @@ The APIs in the `dgraph` namespace are below, organized by category.
2828

2929
### Functions
3030

31-
#### execute
31+
#### alterSchema
3232

33-
Execute a Dgraph query or mutation using a Dgraph Request object.
33+
Alter the schema of a Dgraph database.
3434

3535
```ts
36-
function execute(connectionName: string, request: Request): Response
36+
function alterSchema(connection: string, schema: string): string
3737
```
3838

39-
<ResponseField name="connectionName" type="string" required>
39+
<ResponseField name="connection" type="string" required>
4040
Name of the connection, as [defined in the
41-
manifest](../../app-manifest#connections).
41+
manifest](/modus/app-manifest#connections).
4242
</ResponseField>
4343

44-
<ResponseField name="request" type="Request" required>
45-
A Dgraph [`Request`](#request) object, describing the query or mutation to
46-
execute.
44+
<ResponseField name="schema" type="string" required>
45+
The schema to apply to the Dgraph database.
4746
</ResponseField>
4847

49-
#### alterSchema
48+
#### dropAll
5049

51-
Alter the schema of a Dgraph database.
50+
Drop all data from a Dgraph database.
5251

5352
```ts
54-
function alterSchema(connectionName: string, schema: string): string
53+
function dropAll(connection: string): string
5554
```
5655

57-
<ResponseField name="connectionName" type="string" required>
56+
<ResponseField name="connection" type="string" required>
5857
Name of the connection, as [defined in the
59-
manifest](../../app-manifest#connections).
60-
</ResponseField>
61-
62-
<ResponseField name="schema" type="string" required>
63-
The schema to apply to the Dgraph database.
58+
manifest](/modus/app-manifest#connections).
6459
</ResponseField>
6560

6661
#### dropAttr
6762

6863
Drop an attribute from a Dgraph schema.
6964

7065
```ts
71-
function dropAttr(connectionName: string, attr: string): string
66+
function dropAttr(connection: string, attr: string): string
7267
```
7368

74-
<ResponseField name="connectionName" type="string" required>
69+
<ResponseField name="connection" type="string" required>
7570
Name of the connection, as [defined in the
76-
manifest](../../app-manifest#connections).
71+
manifest](/modus/app-manifest#connections).
7772
</ResponseField>
7873

7974
<ResponseField name="attr" type="string" required>
8075
The attribute to drop from the Dgraph schema.
8176
</ResponseField>
8277

83-
#### dropAll
78+
#### execute
8479

85-
Drop all data from a Dgraph database.
80+
Execute a Dgraph query or mutation using a Dgraph Request object.
8681

8782
```ts
88-
function dropAll(connectionName: string): string
83+
function execute(connection: string, request: Request): Response
8984
```
9085

91-
<ResponseField name="connectionName" type="string" required>
86+
<ResponseField name="connection" type="string" required>
9287
Name of the connection, as [defined in the
93-
manifest](../../app-manifest#connections).
88+
manifest](/modus/app-manifest#connections).
89+
</ResponseField>
90+
91+
<ResponseField name="request" type="Request" required>
92+
A Dgraph [`Request`](#request) object, describing the query or mutation to
93+
execute.
9494
</ResponseField>
9595

96-
### Objects
96+
### Types
9797

98-
#### Request
98+
#### Mutation
9999

100-
A Dgraph request object, used to execute queries and mutations.
100+
A Dgraph mutation object, used to execute mutations.
101101

102102
```ts
103-
class Request {
104-
constructor(Query: Query | null = null, Mutations: Mutation[] | null = null)
105-
query: Query = new Query()
106-
mutations: Mutation[] = []
103+
class Mutation {
104+
setJson: string,
105+
delJson: string,
106+
setNquads: string,
107+
delNquads: string,
108+
condition: string,
107109
}
108110
```
109111

110-
<ResponseField name="new dgraph.Request(query, mutations)">
111-
Creates a new `Request` object with the given `query` and `mutations`.
112+
<ResponseField name="new dgraph.Mutation(setJson, delJson, setNquads, delNquads, condition)">
113+
Creates a new `Mutation` object with the given `setJson`, `delJson`,
114+
`setNquads`, `delNquads`, and `condition` fields.
115+
</ResponseField>
112116

113-
The [`query`](#query) and [`mutations`](#mutation) fields are optional and
114-
default to `null`.
117+
<ResponseField name="setJson" type="string">
118+
A JSON string representing the data to set in the mutation.
119+
</ResponseField>
115120

121+
<ResponseField name="delJson" type="string">
122+
A JSON string representing the data to delete in the mutation.
116123
</ResponseField>
117124

118-
<ResponseField name="query" type="Query">
119-
A Dgraph [`query`](#query) object.
125+
<ResponseField name="setNquads" type="string">
126+
A string representing the data to set in the mutation in NQuads format.
120127
</ResponseField>
121128

122-
<ResponseField name="mutations" type="Mutation[]">
123-
An array of Dgraph [`mutation`](#mutation) objects.
129+
<ResponseField name="delNquads" type="string">
130+
A string representing the data to delete in the mutation in NQuads format.
131+
</ResponseField>
132+
133+
<ResponseField name="condition" type="string">
134+
A string representing the condition query for the mutation.
124135
</ResponseField>
125136

126137
#### Query
@@ -129,7 +140,6 @@ A Dgraph query object, used to execute queries.
129140

130141
```ts
131142
class Query {
132-
constructor(query: string = "", variables: Variables = new Variables())
133143
query: string = ""
134144
variables: Map<string, string> = new Map<string, string>()
135145
}
@@ -149,63 +159,50 @@ class Query {
149159
A map of query variables.
150160
</ResponseField>
151161

152-
#### Variables
162+
#### Request
153163

154-
A Variables object used to set query variables in a Dgraph query.
164+
A Dgraph request object, used to execute queries and mutations.
155165

156166
```ts
157-
class Variables {
158-
public set<T>(name: string, value: T): void
159-
public toMap(): Map<string, string>
167+
class Request {
168+
query: Query = new Query()
169+
mutations: Mutation[] = []
160170
}
161171
```
162172

163-
<ResponseField name="Variables.set(name, value)">
164-
Sets a query variable with the given `name` and `value`. `name` is of type
165-
`string`, and `value` can be of any type.
166-
</ResponseField>
167-
168-
<ResponseField name="Variables.toMap()">
169-
Returns a map of all query variables set in the `Variables` object.
170-
</ResponseField>
173+
<ResponseField name="new dgraph.Request(query, mutations)">
171174

172-
#### Mutation
175+
Creates a new `Request` object with the given `query` and `mutations`.
173176

174-
A Dgraph mutation object, used to execute mutations.
175-
176-
```ts
177-
class Mutation {
178-
constructor(
179-
public setJson: string = "",
180-
public delJson: string = "",
181-
public setNquads: string = "",
182-
public delNquads: string = "",
183-
public condition: string = "",
184-
)
185-
}
186-
```
177+
The [`query`](#query) and [`mutations`](#mutation) fields are optional and
178+
default to `null`.
187179

188-
<ResponseField name="new dgraph.Mutation(setJson, delJson, setNquads, delNquads, condition)">
189-
Creates a new `Mutation` object with the given `setJson`, `delJson`,
190-
`setNquads`, `delNquads`, and `condition` fields.
191180
</ResponseField>
192181

193-
<ResponseField name="setJson" type="string">
194-
A JSON string representing the data to set in the mutation.
182+
<ResponseField name="query" type="Query">
183+
A Dgraph [`query`](#query) object.
195184
</ResponseField>
196185

197-
<ResponseField name="delJson" type="string">
198-
A JSON string representing the data to delete in the mutation.
186+
<ResponseField name="mutations" type="Mutation[]">
187+
An array of Dgraph [`mutation`](#mutation) objects.
199188
</ResponseField>
200189

201-
<ResponseField name="setNquads" type="string">
202-
A string representing the data to set in the mutation in NQuads format.
203-
</ResponseField>
190+
#### Variables
204191

205-
<ResponseField name="delNquads" type="string">
206-
A string representing the data to delete in the mutation in NQuads format.
192+
A Variables object used to set query variables in a Dgraph query.
193+
194+
```ts
195+
class Variables {
196+
set<T>(name: string, value: T): void
197+
toMap(): Map<string, string>
198+
}
199+
```
200+
201+
<ResponseField name="Variables.set(name, value)">
202+
Sets a query variable with the given `name` and `value`. `name` is of type
203+
`string`, and `value` can be of any type.
207204
</ResponseField>
208205

209-
<ResponseField name="condition" type="string">
210-
A string representing the condition query for the mutation.
206+
<ResponseField name="Variables.toMap()">
207+
Returns a map of all query variables set in the `Variables` object.
211208
</ResponseField>

0 commit comments

Comments
 (0)