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: docs-v2/pages/workflows/building-workflows/code/nodejs/using-data-stores.mdx
+46-46Lines changed: 46 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,23 @@ In Node.js (Javascript) code steps, you can also store and retrieve data within
6
6
7
7
Add data stores to steps as props. By adding the store as a prop, it's available under `this`.
8
8
9
-
For example, you can define a data store as a data prop, and reference it at `this.data`:
9
+
For example, you can define a data store as a dataStore prop, and reference it at `this.dataStore`:
10
10
11
11
```javascript
12
12
exportdefaultdefineComponent({
13
13
props: {
14
-
// Define that the "data" variable in our component is a data store
15
-
data: { type:"data_store" },
14
+
// Define that the "dataStore" variable in our component is a data store
15
+
dataStore: { type:"data_store" },
16
16
},
17
17
asyncrun({ steps, $ }) {
18
-
// Now we can access the data store at "this.data"
19
-
awaitthis.data.get("email");
18
+
// Now we can access the data store at "this.dataStore"
19
+
awaitthis.dataStore.get("email");
20
20
},
21
21
});
22
22
```
23
23
24
24
<Callouttype="info">
25
-
**`props` injects variables into `this`**. See how we declared the `data` prop in the `props` object, and then accessed it at `this.data` in the `run` method.
25
+
**`props` injects variables into `this`**. See how we declared the `dataStore` prop in the `props` object, and then accessed it at `this.dataStore` in the `run` method.
26
26
</Callout>
27
27
28
28
<Callouttype="warning">
@@ -37,16 +37,16 @@ Once you've defined a data store prop for your component, then you'll be able to
37
37
38
38
## Saving data
39
39
40
-
Data Stores are key-value stores. Save data within a Data Store using the `this.data.set` method. The first argument is the _key_ where the data should be held, and the second argument is the _value_ assigned to that key.
40
+
Data Stores are key-value stores. Save data within a Data Store using the `this.dataStore.set` method. The first argument is the _key_ where the data should be held, and the second argument is the _value_ assigned to that key.
41
41
42
42
```javascript
43
43
exportdefaultdefineComponent({
44
44
props: {
45
-
data: { type:"data_store" },
45
+
dataStore: { type:"data_store" },
46
46
},
47
47
asyncrun({ steps, $ }) {
48
48
// Store a timestamp each time this step is executed in the workflow
49
-
awaitthis.data.set("lastRanAt", newDate());
49
+
awaitthis.dataStore.set("lastRanAt", newDate());
50
50
},
51
51
});
52
52
```
@@ -58,14 +58,14 @@ You can set an expiration time for a record by passing a TTL (Time-To-Live) opti
58
58
```javascript
59
59
exportdefaultdefineComponent({
60
60
props: {
61
-
data: { type:"data_store" },
61
+
dataStore: { type:"data_store" },
62
62
},
63
63
asyncrun({ steps, $ }) {
64
64
// Store a temporary value that will expire after 1 hour (3600 seconds)
0 commit comments