Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions guides/databases/initial-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can also specify other folders by providing the `--out` option, e.g.:
cds add data -o test/data
```


Each file contains a CSV header line reflecting the structure of the entity to which it corresponds.

## Editing `.csv` Files

Expand All @@ -68,7 +68,7 @@ cds add data --records 10
```

> [!tip] AI-Generated Data
> For more realistic domain-specific data, you can use AI tools, like CoPilot in VS Code, to assist you in that. This works particularly well for small to medium-sized datasets. Even more as CDS models provide easy to reason domain models, combined with strong typing information that AIs can leverage to generate fitting data samples.
> For more realistic domain-specific data, you can use AI tools, like CoPilot in VS Code, to assist you in that. This works particularly well for small to medium-sized datasets. Moreover, CDS models provide domain models that are easy to reason about, with strong typing information, meaning that AIs can generate better fitting data samples.



Expand All @@ -78,7 +78,7 @@ Common rules apply to text content in `.csv` files, like:
| ------------------------------------------------------------ | --------------------------- |
| If texts contain commas, or line breaks, or trailing whitespaces | -> enclose in double quotes |
| If texts contain double quotes | -> escape by doubling them |
| Numeric content shall be treated as texts | -> enclose in double quotes |
| Numeric content should be treated as texts | -> enclose in double quotes |



Expand Down Expand Up @@ -158,13 +158,13 @@ myproject/

All `db/data/*.csv` and `srv/data/*.csv` files are automatically loaded, because they are located in a `data` folder next to `.cds` model sources.

Additionally, this _in-the-neighborhood-of-models_ technique enables reuse packages, which's main purpose is to provide initial data. Such packages get installed via `npm` or `mvn`, and hence their content will reside under `node_modules` folders, or Maven `target` folders. As long as they also provide models through `.cds` sources, their data will be found and loaded.
This is especially useful for remote service definitions imported with `cds import` (by default into `srv/external/`) so that data for such services can also be served when mocking.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This describes sth different than it did before, doesn't it? Is that on purpose?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My addition is intended as just that, an addition. But the deletion (of "Additionally, this ...") is also deliberate, as it occurs pretty much verbatim in the section that follows this, with its own heading.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct ... I copied that paragraphs so often, and ultimately lost all the traces out of sight




## From Reuse Packages

The [_in-the-neighborhood-of-models_](#next-to-cds-files) technique enables reuse packages, which's main purpose is to provide initial data.
The [_in-the-neighborhood-of-models_](#next-to-cds-files) technique enables reuse packages whose main purpose is to provide initial data.

Find an example for such a content reuse package at [*@capire/common*](https://github.com/capire/common) which showcases how one could provide ISO reuse data for `Countries`, `Currencies` and `Languages` code lists, as defined in [`@sap/cds/common`](../../cds/common). It essentially consists of these files as content:

Expand Down
Loading