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: versioned_docs/version-4.6/developers/applications/loading-data.md
+18-9Lines changed: 18 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: Data Loader
2
+
title: Loading Data
3
3
---
4
4
5
-
# Data Loader
5
+
# Loading Data
6
6
7
7
Now that you’ve set up your first application, let’s bring it to life with some data. Applications are only as useful as the information they hold, and Harper makes it simple to seed your database with initial records, configuration values, or even test users, without needing to write a custom script. This is where the Data Loader plugin comes in.
You should see both `Harper` and `Balto` returned as JSON.
70
70
71
+
:::info
72
+
💡 Notice the trailing `/` in the URL (`/Dog/`). This tells Harper to return all records in the table. Leaving it off would look for a single record instead.
73
+
74
+
For more details on querying tables, resources, and records with the REST plugin, see the [REST reference docs](../../developers/rest).
75
+
:::
76
+
71
77
### Updating Records
72
78
73
79
What happens if you change the data file? Let’s update Harper’s age from 3 to 4 in `dogs.json.`
@@ -88,18 +94,20 @@ The Data Loader is designed to be safe and repeatable. If a record already exist
88
94
89
95
### Adding More Tables
90
96
91
-
If your app grows and you want to seed more than just dogs, you can create additional files. For example, a `settings.yaml` file:
97
+
If your app grows and you want to seed more than just dogs, you can create additional files. For example, a `breeds.yaml` file:
92
98
93
99
```yaml
94
100
database: myapp
95
-
table: Settings
101
+
table: Breed
96
102
records:
97
103
- id: 1
98
-
setting_name: app_name
99
-
setting_value: Dog Tracker
104
+
name: Labrador
105
+
size: Large
106
+
lifespan: 12
100
107
- id: 2
101
-
setting_name: version
102
-
setting_value: '1.0.0'
108
+
name: Husky
109
+
size: Medium
110
+
lifespan: 14
103
111
```
104
112
105
113
Then add it to your config:
@@ -108,7 +116,7 @@ Then add it to your config:
108
116
dataLoader:
109
117
files:
110
118
- 'data/dogs.json'
111
-
- 'data/settings.yaml'
119
+
- 'data/breeds.yaml'
112
120
```
113
121
114
122
Harper will read both files and load them into their respective tables.
@@ -123,3 +131,4 @@ In just a few steps, we’ve gone from an empty Dog table to a real application
123
131
124
132
- [Data Loader Reference](../../reference/applications/data-loader) – Complete configuration and format options.
125
133
- [Bulk Operations](../operations-api/bulk-operations) - For loading data via the Operations API
134
+
- [Plugins](../../reference/components/plugins) – For adding custom functionality to applications.
0 commit comments