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
Data source files allow you to seed the database with initial data. This is useful for lookup tables, configuration, or demo content.
4
+
5
+
## 1. Overview
6
+
7
+
-**Implicit Naming**: Name the file `<object_name>.data.yml` to automatically map it to an object.
8
+
-**Explicit Naming**: Use the `object` and `records` properties in the YAML content.
9
+
-**Auto-deduplication**: Currently, data seeding attempts to create records. Duplicate key errors are typically ignored (depending on driver implementation), allowing for basic idempotency.
10
+
11
+
## 2. File Format
12
+
13
+
### Option A: Implicit (Recommended)
14
+
15
+
File Name: `status.data.yml`
16
+
Target Object: `status`
17
+
18
+
```yaml
19
+
- code: "draft"
20
+
label: "Draft"
21
+
is_active: true
22
+
23
+
- code: "published"
24
+
label: "Published"
25
+
is_active: true
26
+
```
27
+
28
+
### Option B: Explicit
29
+
30
+
File Name: `initial_setup.data.yml` (can be anything)
31
+
32
+
```yaml
33
+
object: status
34
+
records:
35
+
- code: "draft"
36
+
label: "Draft"
37
+
38
+
- code: "published"
39
+
label: "Published"
40
+
```
41
+
42
+
### Option C: Multiple Objects (Bundled)
43
+
44
+
Not currently supported in a single file. Please use separate files.
45
+
46
+
## 3. Best Practices
47
+
48
+
1. **Use Immutable IDs**: If possible, provide explicit IDs (`_id`) to ensure consistent referencing across environments.
49
+
2. **Versioning**: Include a metadata field if you need to track data versions.
50
+
3. **Order Matters**: If you have relationships, ensure the parent data is loaded before child data (ObjectQL loads data files in alphabetical order).
0 commit comments