Compare commits
34 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e894313c3 | ||
|
|
83ea6a363d | ||
|
|
98cf14101a | ||
|
|
401ff039ff | ||
|
|
4d8b887389 | ||
|
|
8ab6a7ebf6 | ||
|
|
09eb51fa32 | ||
|
|
7a6a6a0257 | ||
|
|
f17c5bfa57 | ||
|
|
85498a9875 | ||
|
|
19b09645db | ||
|
|
9861b05f2d | ||
|
|
c58bcf905f | ||
|
|
50ab059c13 | ||
|
|
46960159d1 | ||
|
|
02228e5a96 | ||
|
|
d4793177fc | ||
|
|
2787284aad | ||
|
|
61a318b250 | ||
|
|
6e42e5a173 | ||
|
|
bf162c23cc | ||
|
|
9b41615ac8 | ||
|
|
29840afc0b | ||
|
|
fa880e2987 | ||
|
|
90881558dc | ||
|
|
6d3e9a211a | ||
|
|
e694fbaf13 | ||
|
|
43d0373d70 | ||
|
|
b632013b16 | ||
|
|
a6deddf022 | ||
|
|
513bf9711f | ||
|
|
00c99c0e0b | ||
|
|
e042317f82 | ||
|
|
04ab69c48f |
@@ -6,7 +6,7 @@
|
||||
"jest": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
"ecmaVersion": 2017
|
||||
},
|
||||
"globals": {
|
||||
"SELECT": true,
|
||||
|
||||
27
.vscode/launch.json
vendored
27
.vscode/launch.json
vendored
@@ -5,17 +5,19 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "bookshop", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||
"args": [ "--", "cds", "run", "--in-memory" ],
|
||||
"cwd": "${workspaceFolder}/packages/bookshop",
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
},
|
||||
{
|
||||
"name": "cds run ...", "request": "launch", "type": "node", "runtimeExecutable": "npx", "runtimeArgs": [ "-n" ],
|
||||
"args": [ "--", "cds", "run", "--with-mocks", "--in-memory?" ],
|
||||
"name": "cds run",
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"runtimeExecutable": "npx",
|
||||
"runtimeArgs": ["-n"],
|
||||
"args": ["--", "cds", "run", "--with-mocks", "--in-memory?"], // the leading "--" arg ensures it works with as well as without debugging
|
||||
"cwd": "${workspaceFolder}/packages/${input:service}",
|
||||
"console": "integratedTerminal",
|
||||
"serverReadyAction": {
|
||||
"pattern": "server listening on (https?://\\S+|[0-9]+)",
|
||||
"uriFormat": "http://localhost:%s",
|
||||
"action": "openExternally"
|
||||
},
|
||||
"skipFiles": ["<node_internals>/**"]
|
||||
}
|
||||
],
|
||||
@@ -29,9 +31,12 @@
|
||||
"bookstore",
|
||||
"media-server",
|
||||
"office-supplies",
|
||||
"reviews-service"
|
||||
"orders-service",
|
||||
"products-service",
|
||||
"reviews-service",
|
||||
"user-service"
|
||||
],
|
||||
"default": "bookshop"
|
||||
"default": "bookstore"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/.gitignore": true,
|
||||
"**/.vscode": true
|
||||
"**/.gitignore": false,
|
||||
"**/.git": false,
|
||||
"**/.vscode": false
|
||||
}
|
||||
}
|
||||
|
||||
21
.vscode/tasks.json
vendored
21
.vscode/tasks.json
vendored
@@ -4,14 +4,23 @@
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm", "script": "watch", "path": "packages/bookshop/",
|
||||
"options": { "env": { "PORT": "4004" }},
|
||||
"presentation": { "group": "A" }
|
||||
"type": "shell", "label": "cds run bookshop",
|
||||
"command": "npx", "args": [ "cds", "watch", "packages/bookshop" ],
|
||||
"presentation": { "group": "A" },
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "npm", "script": "watch", "path": "packages/reviews-service/",
|
||||
"options": { "env": { "PORT": "5005" }},
|
||||
"presentation": { "group": "A" }
|
||||
"type": "shell", "label": "cds run bookshop-enhanced",
|
||||
"command": "npx", "args": [ "cds", "watch", "packages/bookshop-enhanced" ],
|
||||
"presentation": { "group": "A" },
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell", "label": "cds run reviews-service",
|
||||
"command": "npx", "args": [ "cds", "watch", "packages/reviews-service" ],
|
||||
"options": {"env": { "PORT":"5005" }},
|
||||
"presentation": { "group": "A" },
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
24
Jenkinsfile
vendored
24
Jenkinsfile
vendored
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
/*
|
||||
* This file bootstraps the codified Continuous Delivery pipeline for extensions of SAP solutions, such as SAP S/4HANA.
|
||||
* The pipeline helps you to deliver software changes quickly and in a reliable manner.
|
||||
* A suitable Jenkins instance is required to run the pipeline.
|
||||
* The Jenkins can easily be bootstraped using the life-cycle script located inside the 'cx-server' directory.
|
||||
*
|
||||
* More information on getting started with Continuous Delivery can be found in the following places:
|
||||
* - GitHub repository: https://github.com/SAP/cloud-s4-sdk-pipeline
|
||||
* - Blog Post: https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
|
||||
*/
|
||||
|
||||
/*
|
||||
* Set pipelineVersion to a fixed released version (e.g. "v15") when running in a productive environment.
|
||||
* To find out about available versions and release notes, visit: https://github.com/SAP/cloud-s4-sdk-pipeline/releases
|
||||
*/
|
||||
String pipelineVersion = "v28"
|
||||
|
||||
node {
|
||||
deleteDir()
|
||||
sh "git clone --depth 1 https://github.com/SAP/cloud-s4-sdk-pipeline.git -b ${pipelineVersion} pipelines"
|
||||
load './pipelines/s4sdk-pipeline.groovy'
|
||||
}
|
||||
29
README.md
29
README.md
@@ -2,20 +2,6 @@
|
||||
|
||||
Find here the samples for the openSAP course [Building Applications with the SAP Cloud Application Programming Model](https://open.sap.com/courses/cp7).
|
||||
|
||||
## Notes on the Demo in Week 4 Unit 4
|
||||
To add all pipeline specific file to your project, run the following command:
|
||||
|
||||
```sh
|
||||
cds add pipeline
|
||||
```
|
||||
|
||||
Details on how to start your Jenkins in your own environment can be found in the [Operations Guide](https://github.com/SAP/devops-docker-cx-server/blob/master/docs/operations/cx-server-operations-guide.md).
|
||||
|
||||
Please note that other than shown in the video Jenkins now is secured by default with an admin user and password.
|
||||
After you have started Jenkins with the command `cx-server start`, you can get the initial password by running `./cx-server initial-credentials`.
|
||||
|
||||
The pipeline documentation can be found [here](https://sap.github.io/jenkins-library/pipelines/cloud-sdk/introduction/).
|
||||
|
||||
## Get Access to SAP Business Application Studio
|
||||
The recommended environment for the course is SAP Business Application Studio. Watch [unit 2 of week 1](https://open.sap.com/courses/cp7/items/51pzQUzbXHr2kdbOmVs6jI) for how to get access.
|
||||
|
||||
@@ -25,8 +11,8 @@ In SAP Business Application Studio, open a terminal.
|
||||
Then clone the repo with this specific branch:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples -b openSAP-week4-unit4
|
||||
cd cloud-cap-samples
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit1
|
||||
cd projects/cloud-cap-samples
|
||||
```
|
||||
|
||||
In the `cloud-cap-samples` folder run:
|
||||
@@ -34,6 +20,17 @@ In the `cloud-cap-samples` folder run:
|
||||
npm install
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
Now you're ready to run the samples, for example:
|
||||
```sh
|
||||
cd packages/bookshop
|
||||
cds watch
|
||||
```
|
||||
|
||||
After that, watch out for the little popup in the lower right corner of SAP Business Application Studio that asks you to open the application in your browser.
|
||||
|
||||
|
||||
## Get Support
|
||||
|
||||
Check out the cap docs at https://cap.cloud.sap. <br>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code
|
||||
7e2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-01-31;john.doe@test.com;;1;EUR
|
||||
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;jane.doe@test.com;;2;EUR
|
||||
|
@@ -1,35 +0,0 @@
|
||||
namespace sap.capire.bookshop;
|
||||
using { Currency, managed, cuid } from '@sap/cds/common';
|
||||
|
||||
entity Books : managed {
|
||||
key ID : Integer;
|
||||
title : localized String(111);
|
||||
descr : localized String(1111);
|
||||
author : Association to Authors;
|
||||
stock : Integer;
|
||||
price : Decimal(9,2);
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
entity Authors : managed {
|
||||
key ID : Integer;
|
||||
name : String(111);
|
||||
dateOfBirth : Date;
|
||||
dateOfDeath : Date;
|
||||
placeOfBirth : String;
|
||||
placeOfDeath : String;
|
||||
books : Association to many Books on books.author = $self;
|
||||
}
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String @title:'Order Number'; //> readable key
|
||||
Items : Composition of many OrderItems on Items.parent = $self;
|
||||
total : Decimal(9,2) @readonly;
|
||||
currency : Currency;
|
||||
}
|
||||
entity OrderItems : cuid {
|
||||
parent : Association to Orders;
|
||||
book : Association to Books;
|
||||
amount : Integer;
|
||||
netAmount : Decimal(9,2);
|
||||
}
|
||||
1
lerna.json
Normal file
1
lerna.json
Normal file
@@ -0,0 +1 @@
|
||||
{"packages":["packages/*"],"version":"1.0.0"}
|
||||
64
mta.yaml
64
mta.yaml
@@ -1,64 +0,0 @@
|
||||
####### Generated mta.yaml based on template version 0.2.0
|
||||
####### appName = capire-bookshop
|
||||
####### language=nodejs; multiTenant=
|
||||
####### approuter=
|
||||
|
||||
_schema-version: '3.1'
|
||||
ID: sap.capire-bookshop
|
||||
version: 1.0.0
|
||||
description: "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages."
|
||||
|
||||
build-parameters:
|
||||
before-all:
|
||||
- builder: custom
|
||||
commands:
|
||||
- npm install
|
||||
- cds build/all
|
||||
|
||||
parameters:
|
||||
enable-parallel-deployments: true
|
||||
|
||||
modules:
|
||||
############## SERVER MODULE ##########################
|
||||
- name: capire-bookshop-srv
|
||||
type: nodejs
|
||||
path: gen/srv
|
||||
properties:
|
||||
EXIT: 1 # required by deploy.js task to terminate
|
||||
|
||||
|
||||
requires:
|
||||
#### Resources extracted from CAP configuration ####
|
||||
- name: capire-bookshop-db
|
||||
|
||||
provides:
|
||||
- name: srv-binding # required by consumers of CAP services (e.g. approuter)
|
||||
properties:
|
||||
srv-url: ${default-url}
|
||||
|
||||
############################################################
|
||||
|
||||
############## SIDECAR MODULE #########################
|
||||
- name: db
|
||||
|
||||
type: hdb
|
||||
path: gen/db
|
||||
parameters:
|
||||
app-name: capire-bookshop-db
|
||||
requires:
|
||||
#### Hana and xsuaa resources extracted from CAP configuration ####
|
||||
- name: capire-bookshop-db
|
||||
############################################################
|
||||
|
||||
|
||||
############## RESOURCES ##################################
|
||||
resources:
|
||||
##### Services extracted from CAP configuration ####
|
||||
##### 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
|
||||
- name: capire-bookshop-db
|
||||
type: com.sap.xs.hdi-container
|
||||
|
||||
parameters:
|
||||
properties:
|
||||
hdi-service-name: ${service-name} # required for Java case
|
||||
############################################################
|
||||
864
package-lock.json
generated
864
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@@ -1,29 +1,28 @@
|
||||
{
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"name": "@sap/capire-samples",
|
||||
"description": "The umbrella project for all samples to easily setup for local development and tests.",
|
||||
"repository": "https://github.com/SAP-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||
"test": "jest",
|
||||
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
||||
"bookshop": "cds watch packages/bookshop",
|
||||
"bookstore": "cds watch packages/bookstore",
|
||||
"products-service": "cds watch packages/products-service",
|
||||
"reviews-service": "cds watch packages/reviews-service"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "^3",
|
||||
"express": "^4",
|
||||
"@sap/hana-client": "^2.4.182"
|
||||
"express": "^4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "^4.1.1"
|
||||
"--add-these-to-devDependencies-for-tests": {
|
||||
"@types/jest": "*",
|
||||
"sqlite3": "*",
|
||||
"jest": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run",
|
||||
"watch": "cds watch"
|
||||
},
|
||||
"cds": {
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "hana",
|
||||
"model": [
|
||||
"db",
|
||||
"srv"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
"license": "SAP SAMPLE CODE LICENSE"
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
|
||||
data-sap-ui-compatVersion="edge"
|
||||
data-sap-ui-theme="sap_fiori_3"
|
||||
data-sap-ui-theme="sap_belize"
|
||||
data-sap-ui-frameOptions="allow"
|
||||
></script>
|
||||
<script>
|
||||
5
packages/bookshop/db/data/sap.capire.bookshop-Orders.csv
Normal file
5
packages/bookshop/db/data/sap.capire.bookshop-Orders.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
ID;modifiedAt;createdAt;createdBy;modifiedBy;OrderNo;currency_code;status
|
||||
da86efd0-4ba1-4078-b7f0-5c9c530297f7;;2019-01-31;ALICE;;1;EUR;processing
|
||||
2f2f2640-6866-4dcf-8f4d-3027aa831cad;;2019-03-25;ALICE;;10;EUR;completed
|
||||
64e718c9-ff99-47f1-8ca3-950c850777d4;;2019-01-30;BOB;;2;EUR;processing
|
||||
1af3322d-3cb1-46be-b312-0ae9ec311537;;2019-03-16;BOB;;9;EUR;completed
|
||||
|
50
packages/bookshop/db/schema.cds
Normal file
50
packages/bookshop/db/schema.cds
Normal file
@@ -0,0 +1,50 @@
|
||||
namespace sap.capire.bookshop;
|
||||
|
||||
using {
|
||||
Currency,
|
||||
managed,
|
||||
cuid
|
||||
} from '@sap/cds/common';
|
||||
|
||||
type Status : String enum {
|
||||
completed;
|
||||
processing;
|
||||
blocked;
|
||||
}
|
||||
|
||||
entity Books : managed {
|
||||
key ID : Integer;
|
||||
title : localized String(111);
|
||||
descr : localized String(1111);
|
||||
author : Association to Authors;
|
||||
stock : Integer;
|
||||
price : Decimal(9, 2);
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
entity Authors : managed {
|
||||
key ID : Integer;
|
||||
name : String(111);
|
||||
dateOfBirth : Date;
|
||||
dateOfDeath : Date;
|
||||
placeOfBirth : String;
|
||||
placeOfDeath : String;
|
||||
books : Association to many Books
|
||||
on books.author = $self;
|
||||
}
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String @title : 'Order Number'; //> readable key
|
||||
status : Status default 'processing';
|
||||
Items : Composition of many OrderItems
|
||||
on Items.parent = $self;
|
||||
total : Decimal(9, 2)@readonly;
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
entity OrderItems : cuid {
|
||||
parent : Association to Orders;
|
||||
book : Association to Books;
|
||||
amount : Integer;
|
||||
netAmount : Decimal(9, 2);
|
||||
}
|
||||
17
packages/bookshop/package.json
Normal file
17
packages/bookshop/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"dependencies": {
|
||||
"@sap/cds": "^3",
|
||||
"express": "^4",
|
||||
"@sap/xb-msg-amqp-v100": "^0.9.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "^4.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npx cds run"
|
||||
}
|
||||
}
|
||||
26
packages/bookshop/srv/cat-service.js
Normal file
26
packages/bookshop/srv/cat-service.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const cds = require('@sap/cds')
|
||||
|
||||
/** Service implementation for CatalogService */
|
||||
module.exports = cds.service.impl(function () {
|
||||
const { Books, Orders } = this.entities
|
||||
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
||||
this.before('CREATE', Orders, _reduceStock)
|
||||
|
||||
/** Add some discount for overstocked books */
|
||||
function _addDiscount2(each, discount) {
|
||||
each.title += ` -- ${discount}% discount!`
|
||||
}
|
||||
|
||||
/** Reduce stock of ordered books if available stock suffices */
|
||||
async function _reduceStock(req) {
|
||||
const { Items: OrderItems } = req.data
|
||||
return cds.transaction(req).run(() => OrderItems.map(order =>
|
||||
UPDATE(Books).set('stock -=', order.amount)
|
||||
.where('ID =', order.book_ID).and('stock >=', order.amount)
|
||||
)).then(all => all.forEach((affectedRows, i) => {
|
||||
if (affectedRows === 0) req.error(409,
|
||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||
)
|
||||
}))
|
||||
}
|
||||
})
|
||||
@@ -1,47 +0,0 @@
|
||||
###
|
||||
# This file configures the SAP Cloud SDK Continuous Delivery pipeline of your project.
|
||||
# For a reference of the configuration concept and available options, please have a look into its documentation.
|
||||
#
|
||||
# The documentation for the most recent pipeline version can always be found at:
|
||||
# https://github.com/SAP/cloud-s4-sdk-pipeline/blob/master/configuration.md
|
||||
# If you are using a fixed version of the pipeline, please make sure to view the corresponding version from the tag
|
||||
# list of GitHub (e.g. "v15" when you configured pipelineVersion = "v15" in the Jenkinsfile).
|
||||
#
|
||||
# For general information on how to get started with Continuous Delivery, visit:
|
||||
# https://blogs.sap.com/2017/09/20/continuous-integration-and-delivery
|
||||
#
|
||||
# We aim to keep the pipeline configuration as stable as possible. However, major changes might also imply breaking
|
||||
# changes in the configuration. Before doing an update, please check the the release notes of all intermediate releases
|
||||
# and adapt this file if necessary.
|
||||
#
|
||||
# This is a YAML-file. YAML is a indentation-sensitive file format. Please make sure to properly indent changes to it.
|
||||
###
|
||||
|
||||
|
||||
|
||||
### General project setup
|
||||
general:
|
||||
productiveBranch: 'openSAP-week4-unit4'
|
||||
|
||||
### Step-specific configuration
|
||||
steps:
|
||||
|
||||
|
||||
### Stage-specific configuration
|
||||
stages:
|
||||
|
||||
# integrationTests:
|
||||
# credentials:
|
||||
# - alias: 'mySystemAlias'
|
||||
# credentialId: 'mySystemCredentialsId'
|
||||
|
||||
# s4SdkQualityChecks:
|
||||
# nonErpDestinations:
|
||||
# - 'myCustomDestination'
|
||||
|
||||
# productionDeployment:
|
||||
# cfTargets:
|
||||
# - org: 'myOrg'
|
||||
# space: 'mySpace'
|
||||
# apiEndpoint: 'https://api.cf.eu10.hana.ondemand.com'
|
||||
# credentialsId: 'cf-deploy-sap'
|
||||
@@ -1,26 +0,0 @@
|
||||
const cds = require('@sap/cds')
|
||||
const { Books } = cds.entities
|
||||
|
||||
/** Service implementation for CatalogService */
|
||||
module.exports = cds.service.impl(function() {
|
||||
this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
||||
this.before ('CREATE', 'Orders', _reduceStock)
|
||||
})
|
||||
|
||||
/** Add some discount for overstocked books */
|
||||
function _addDiscount2 (each,discount) {
|
||||
each.title += ` -- ${discount}% discount!`
|
||||
}
|
||||
|
||||
/** Reduce stock of ordered books if available stock suffices */
|
||||
async function _reduceStock (req) {
|
||||
const { Items: OrderItems } = req.data
|
||||
return cds.transaction(req) .run (()=> OrderItems.map (order =>
|
||||
UPDATE (Books) .set ('stock -=', order.amount)
|
||||
.where ('ID =', order.book_ID) .and ('stock >=', order.amount)
|
||||
)) .then (all => all.forEach ((affectedRows,i) => {
|
||||
if (affectedRows === 0) req.error (409,
|
||||
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
|
||||
)
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user