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
{{ message }}
This repository was archived by the owner on Nov 13, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: exercises/02/readme.md
+20-17Lines changed: 20 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,31 +65,30 @@ user@host:~
65
65
=> cds init --help
66
66
```
67
67
68
-
Amongst other things, you should see a `--modules` option to specify a list of modules to be created when the project is initialized, and also a `--verbose` option.
68
+
Amongst other things, you should see a `--modules` option to specify a list of modules to be created when the project is initialized, and also a `--verbose` option. The options `--mta`, `--db-technology` and `--insecure` are related to deployment to Cloud Foundry and its access management.
69
69
70
-
:point_right: Use both of these options to initialize a new project directory thus:
70
+
:point_right: Use all of these options to initialize a new project directory thus:
Copying templates for type srv to bookshop/srv ...
84
-
Updating npm dependencies in bookshop/package.json ...
79
+
```
80
+
[Warn] Srv type nodejs only supports odata version v4 and not v2. Will use v4.
81
+
Initializing project in folder bookshop.
82
+
Copying templates for type db to db ...
83
+
Creating mta file /Users/d056949/SoftwareDev/sandbox/bookshop/mta.yaml ...
84
+
Copying templates for type srv to {{moduleFolder}} ...
85
+
Creating mta file /Users/d056949/SoftwareDev/sandbox/bookshop/mta.yaml ...
86
+
Updating npm dependencies in /Users/d056949/SoftwareDev/sandbox/bookshop/package.json ...
85
87
Running npm install...
86
-
npm WARN bookshop@1.0.0 license should be a valid SPDX license expression
87
-
88
-
added 76 packages from 109 contributors and audited 166 packages in 3.261s
88
+
added 81 packages from 111 contributors and audited 176 packages in 2.976s
89
89
found 0 vulnerabilities
90
90
91
-
92
-
Project creation was successful.
91
+
Finished successfully.
93
92
```
94
93
95
94
@@ -123,6 +122,7 @@ Briefly, the directories and contents can be described thus:
123
122
| `db` | Where the data models (in CDS) are specified. A skeleton CDS project that has been initialized with the `--modules db` option will have a basic data model file in the form of `data-model.cds` with a small sample definition, like here |
124
123
| `node_modules` | This is the normal place where NPM packages (modules) are to be found in a Node.js based project |
125
124
| `srv` | Where the service definitions (in CDS) are specified. A skeleton CDS project that has been initialized with the `--modules srv` option will have a basic service definition file in the form of `cat-service.cds` with a small service definition, like here |
125
+
| `mta.yaml` | This is the central descriptor file for the project. It defines all modules (microservices) and backing services (like databases). This information will be used (a) to build the .mtar archive during design time and to deploy and provision the apps and services during deploy time. |
126
126
127
127
Besides the directories there are also a number of files, including the project's `package.json` (present in any Node.js based project) and a readme file.
128
128
@@ -158,14 +158,15 @@ Note: You can also specify simply `cds serve all` to have `cds` look for appropr
158
158
You should see output similar to this:
159
159
160
160
```
161
-
[cds] - server listening at http://localhost:4004
161
+
[cds] - connect to datasource - hana:db,srv
162
162
[cds] - serving CatalogService at /catalog
163
163
[cds] - service definitions loaded from:
164
164
165
165
srv/cat-service.cds
166
166
db/data-model.cds
167
167
168
-
[cds] - launched in: 448.633ms
168
+
[cds] - server listens at http://localhost:4004 ... (terminate with ^C)
169
+
[cds] - launched in: 566.451ms
169
170
```
170
171
171
172
The OData service is now running, and available on [http://localhost:4004](http://localhost:4004).
@@ -183,7 +184,7 @@ The [catalog](http://localhost:4004/catalog) link will take you to the service d
183
184
184
185
:point_right: Explore the metadata document and familiarize yourself with the content. Note the entityset definition and the entity type describing the `Books` entity. Note also the annotations describing particular service capabilities.
185
186
186
-
:point_right: There is also a link to the [Books](http://localhost:4004/catalog/Books) entityset. Follow this link to see what the service returns.
187
+
:point_right: There is also a link to the [Books](http://localhost:4004/catalog/Books) entityset. Follow this link to see what the service returns. Check what happens to the node process when you try to access the entityset.
187
188
188
189
189
190
## Summary
@@ -200,3 +201,5 @@ With a single command, you've initialized a basic OData service project and with
200
201
1. What are the annotations in the metadata document describing, and where do they come from?
201
202
202
203
1. What does the Books entityset resource contain right now?
204
+
205
+
1. What happened to the node process when you accessed the entityset? Can you think of reasons why this happened?
Copy file name to clipboardExpand all lines: exercises/03/readme.md
+46-27Lines changed: 46 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,50 @@ Don't forget to save the file.
105
105
106
106
As it stands, the OData service has no storage. We can actually simulate storage with [service provider](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/b9c34890348b4f2184e07a6731bce50b.html) logic in JavaScript but that's not a path we want to explore right now (we'll look at it in [exercise 08](../08/)). Instead, we'll use a real database in the form of [SQLite](https://sqlite.org) and deploy the data model and service definition to it.
107
107
108
-
_Note: From cds 3.10 onwards, the `sqlite3` package is automatically installed in the project for you as a development dependency so it's all ready for you to start using._
108
+
:point_right: Update the database definition in `package.json` to include a SQLite DB for local testing. This will fix the issue you encountered before when the node process crashed. Currently, you'll see a section that describes the persistence layer configuration:
109
+
110
+
```json
111
+
"cds": {
112
+
"requires": {
113
+
"db": {
114
+
"kind": "hana",
115
+
"model": [
116
+
"db",
117
+
"srv"
118
+
]
119
+
}
120
+
},
121
+
"odata": {
122
+
"version": "v4"
123
+
}
124
+
}
125
+
```
126
+
To prepare the app for a multiple databases, change the content to:
127
+
```json
128
+
"cds": {
129
+
"requires": {
130
+
"db": {
131
+
"kind": "sqlite",
132
+
"model": ["db", "srv"],
133
+
"credentials": {
134
+
"database": "bookshop.db"
135
+
},
136
+
"[production]": {
137
+
"kind": "hana"
138
+
}
139
+
}
140
+
},
141
+
"odata": {
142
+
"version": "v4"
143
+
}
144
+
}
145
+
```
146
+
147
+
:point_right: As we want to use a local SQLite database, we need to install a client to communicate with this DB. Install the `sqlite3` package for this job.
148
+
```
149
+
npm install -D sqlite3
150
+
```
151
+
109
152
110
153
:point_right: Explore the `cds deploy` command like this:
111
154
@@ -128,34 +171,10 @@ Use this command to deploy the data model and service definition to a new SQLite
128
171
129
172
```
130
173
user@host:~/bookshop
131
-
=> cds deploy --to sqlite:bookshop.db
132
-
```
133
-
134
-
This should complete fairly quietly, and give a message like this:
135
-
136
-
```
137
-
- updated package.json
138
-
```
139
-
140
-
Note: If you're wondering what is been updated in `package.json` relating to the use of SQLite, have a look. You'll see a section that describes the persistence layer configuration:
0 commit comments