@@ -133,36 +133,120 @@ module.exports = class Service1 extends cds.ApplicationService {
133133 } ) ;
134134
135135 /* ========== 2. Service1 running query on itself by `await`-ing the query ========== */
136- this . on ( "send21 " , async ( req ) => {
136+ this . on ( "send00211 " , async ( req ) => {
137137 const { id } = req . data ;
138138 const { Service1Entity } = this . entities ;
139139 await SELECT . from ( Service1Entity ) . where ( "ID=" + id ) ;
140140 } ) ;
141141
142- this . on ( "send22 " , async ( req ) => {
142+ this . on ( "send00212 " , async ( req ) => {
143143 const { id } = req . data ;
144144 const { Service1Entity } = this . entities ;
145- await INSERT . into ( Service1Entity ) . entries ( { id : "" + id } ) ;
145+ await SELECT . from ( Service1Entity ) . where ( `ID=` + id ) ;
146146 } ) ;
147147
148- this . on ( "send23" , async ( req ) => {
149- const { id, amount } = req . data ;
148+ this . on ( "send00213" , async ( req ) => {
149+ const { id } = req . data ;
150+ const { Service1Entity } = this . entities ;
151+ await SELECT . from ( Service1Entity ) . where ( `ID=${ id } ` ) ;
152+ } ) ;
153+
154+ this . on ( "send00214" , async ( req ) => {
155+ const { id } = req . data ;
156+ const { Service1Entity } = this . entities ;
157+ await SELECT . from ( Service1Entity ) . where `ID=${ id } ` ;
158+ } ) ;
159+
160+ this . on ( "send00221" , async ( req ) => {
161+ const { id } = req . data ;
162+ const { Service1Entity } = this . entities ;
163+ await INSERT . into ( Service1Entity ) . entries ( "ID =" + id ) ;
164+ } ) ;
165+
166+ this . on ( "send00222" , async ( req ) => {
167+ const { id } = req . data ;
168+ const { Service1Entity } = this . entities ;
169+ await INSERT . into ( Service1Entity ) . entries ( `ID =` + id ) ;
170+ } ) ;
171+
172+ this . on ( "send00223" , async ( req ) => {
173+ const { id } = req . data ;
174+ const { Service1Entity } = this . entities ;
175+ await INSERT . into ( Service1Entity ) . entries ( `ID = ${ id } ` ) ;
176+ } ) ;
177+
178+ this . on ( "send00224" , async ( req ) => {
179+ const { id } = req . data ;
180+ const { Service1Entity } = this . entities ;
181+ await INSERT . into ( Service1Entity ) . entries `ID = ${ id } ` ;
182+ } ) ;
183+
184+ this . on ( "send00231" , async ( req ) => {
185+ const { id } = req . data ;
186+ const { Service1Entity } = this . entities ;
187+ await UPDATE . entity ( Service1Entity ) . set ( "col1 = col1 + " + id ) . where ( "ID =" + id ) ;
188+ } ) ;
189+
190+ this . on ( "send00232" , async ( req ) => {
191+ const { id } = req . data ;
192+ const { Service1Entity } = this . entities ;
193+ await UPDATE . entity ( Service1Entity ) . set ( "col1 = col1 + " + id ) . where ( `ID =` + id ) ;
194+ } ) ;
195+
196+ this . on ( "send00233" , async ( req ) => {
197+ const { id } = req . data ;
150198 const { Service1Entity } = this . entities ;
151- await UPDATE . entity ( Service1Entity ) . set ( ` col1 = col1 -` + amount ) . where ( "id=" + id ) ;
199+ await UPDATE . entity ( Service1Entity ) . set ( " col1 = col1 + " + id ) . where ( `ID = ${ id } ` ) ;
152200 } ) ;
153201
154- this . on ( "send24" , async ( req ) => {
202+ this . on ( "send00234" , async ( req ) => {
203+ const { id } = req . data ;
204+ const { Service1Entity } = this . entities ;
205+ await UPDATE . entity ( Service1Entity ) . set ( "col1 = col1 + " + id ) . where `ID = ${ id } ` ;
206+ } ) ;
207+
208+ this . on ( "send00241" , async ( req ) => {
155209 const { id } = req . data ;
156210 const { Service1Entity } = this . entities ;
157211 await UPSERT . into ( Service1Entity ) . entries ( { id : "" + id } ) ;
158212 } ) ;
159213
160- this . on ( "send25" , async ( req ) => {
214+ this . on ( "send00242" , async ( req ) => {
215+ const { id } = req . data ;
216+ const { Service1Entity } = this . entities ;
217+ await UPSERT . into ( Service1Entity ) . entries ( { id : `` + id } ) ;
218+ } ) ;
219+
220+ this . on ( "send00243" , async ( req ) => {
221+ const { id } = req . data ;
222+ const { Service1Entity } = this . entities ;
223+ await UPSERT . into ( Service1Entity ) . entries ( { id : `${ id } ` } ) ;
224+ } ) ;
225+
226+ this . on ( "send00251" , async ( req ) => {
161227 const { id } = req . data ;
162228 const { Service1Entity } = this . entities ;
163229 await DELETE . from ( Service1Entity ) . where ( "ID =" + id ) ;
164230 } ) ;
165231
232+ this . on ( "send00252" , async ( req ) => {
233+ const { id } = req . data ;
234+ const { Service1Entity } = this . entities ;
235+ await DELETE . from ( Service1Entity ) . where ( `ID =` + id ) ;
236+ } ) ;
237+
238+ this . on ( "send00253" , async ( req ) => {
239+ const { id } = req . data ;
240+ const { Service1Entity } = this . entities ;
241+ await DELETE . from ( Service1Entity ) . where ( `ID = ${ id } ` ) ;
242+ } ) ;
243+
244+ this . on ( "send00254" , async ( req ) => {
245+ const { id } = req . data ;
246+ const { Service1Entity } = this . entities ;
247+ await DELETE . from ( Service1Entity ) . where `ID = ${ id } ` ;
248+ } ) ;
249+
166250 /* ========== 3. Service1 running query on itself using `this.run` and friends using Fluent API ========== */
167251 this . on ( "send31" , async ( req ) => {
168252 const { id } = req . data ;
@@ -301,13 +385,25 @@ module.exports = class Service1 extends cds.ApplicationService {
301385 /* ========== 7. Service1 running query on the database service using CQN parsed with global function `CQL` ========== */
302386 this . on ( "send71" , async ( req ) => {
303387 const { id } = req . data ;
304- const query = CQL ( ` SELECT * from Entity1 where ID =` + id ) ; // TP
388+ const query = CQL ( " SELECT * from Entity1 where ID =" + id ) ;
305389 cds . run ( query ) ;
306390 } ) ;
307391
308392 this . on ( "send72" , async ( req ) => {
309393 const { id } = req . data ;
310- const query = CQL `SELECT * from Entity1 where ID =` + id ; // FP
394+ const query = CQL ( `SELECT * from Entity1 where ID =` + id ) ;
395+ cds . run ( query ) ;
396+ } ) ;
397+
398+ this . on ( "send73" , async ( req ) => {
399+ const { id } = req . data ;
400+ const query = CQL `SELECT * from Entity1 where ID = ${ id } ` ;
401+ cds . run ( query ) ;
402+ } ) ;
403+
404+ this . on ( "send74" , async ( req ) => {
405+ const { id } = req . data ;
406+ const query = CQL ( `SELECT * from Entity1 where ID = ${ id } ` ) ;
311407 cds . run ( query ) ;
312408 } ) ;
313409
@@ -566,6 +662,5 @@ module.exports = class Service1 extends cds.ApplicationService {
566662 const { id } = req . data ;
567663 cds . db . delete ( "Entity1" ) . where ( "ID =" + id ) ;
568664 } ) ;
569-
570665 }
571666} ;
0 commit comments